comparison lisp/org/org.el @ 109462:a150e8a14679

Install version 7.01 of Org-mode 2010-07-19 Eric Schulte <schulte.eric@gmail.com> * ob-C.el: New file. * ob-R.el: New file. * ob-asymptote.el: New file. * ob-clojure.el: New file. * ob-comint.el: New file. * ob-css.el: New file. * ob-ditaa.el: New file. * ob-dot.el: New file. * ob-emacs-lisp.el: New file. * ob-eval.el: New file. * ob-exp.el: New file. * ob-gnuplot.el: New file. * ob-haskell.el: New file. * ob-keys.el: New file. * ob-latex.el: New file. * ob-lob.el: New file. * ob-matlab.el: New file. * ob-mscgen.el: New file. * ob-ocaml.el: New file. * ob-octave.el: New file. * ob-perl.el: New file. * ob-python.el: New file. * ob-ref.el: New file. * ob-ruby.el: New file. * ob-sass.el: New file. * ob-screen.el: New file. * ob-sh.el: New file. * ob-sql.el: New file. * ob-sqlite.el: New file. * ob-table.el: New file. * ob-tangle.el: New file. * ob.el: New file. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-mks.el: New file. * org-capture.el: New file. 2010-07-19 Christian Egli <christian.egli@sbszh.ch> * org-taskjuggler.el: New file. 2010-07-19 Matt Lundin <mdl@imapmail.org> * org-agenda.el (org-search-view): Fixed inclusion of agenda-archives in org-agenda-text-search-extra-files. 2010-07-19 David Maus <dmaus@ictsoc.de> * org-list.el (org-list-send-list): Locally bind variable `txt'. 2010-07-19 Eric Schulte <schulte.eric@gmail.com> * org.el (org-reload): now also reloading babel files 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-capture.el (org-capture-set-plist): Make sure txt is a string before calling `string-match'. (org-capture-templates): Fix customization type. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-latex.el (org-export-latex-preprocess): Make a special case for \nbsp. (org-latex-entities): Remove the entry for \nbsp. (org-latex-entities-exceptions): Variable removed. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-capture.el (org-capture-refile): Do not try to manipulate bookmark list. * org.el (org-refile): Use the correct bookmark here. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-list.el (org-list-send-list): Parse list from its true beginning. * org.el (org-ctrl-c-ctrl-c): Maybe send the list when at a list item. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-insert-link): Correctly determine if we should use a relative path. 2010-07-19 Nicolas Goaziou <n.goaziou@gmail.com> * org-list.el (org-list-radio-list-templates): Fix templates. 2010-07-19 Nicolas Goaziou <n.goaziou@gmail.com> * org-list.el (org-list-send-list): regexp defining the start of a radio list is now on par with the one used for radio tables. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-entities.el (org-entities-help): Add a headline for the user-defined entities. 2010-07-19 Dirk-Jan C. Binnema <djcb.bulk@gmail.com> (tiny change) * org-agenda.el (org-agenda-action): Document capture key and add it to the prompt. 2010-07-19 Eric Schulte <schulte.eric@gmail.com> * org-latex.el (org-export-latex-listings-langs): added (sqlite "SQL") 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-latex.el (org-export-latex-first-lines): Do not mark meta lines for removal. Do not remove BABEL config lines during export 2010-07-19 David Maus <dmaus@ictsoc.de> * org-capture.el (org-capture): Check if `org-capture-link-is-already-stored' is bound before evaluating. 2010-07-19 Eric Schulte <schulte.eric@gmail.com> * org.el: added autoload for org-babel-do-load-languages 2010-07-19 Eric Schulte <schulte.eric@gmail.com> * org-src.el (org-src-lang-modes): added sqlite to sql-mode 2010-07-19 David Maus <dmaus@ictsoc.de> * org-feed.el: Change indentation to match coding style guideline. 2010-07-19 David Maus <dmaus@ictsoc.de> * org-feed.el (org-feed-unescape, org-feed-parse-atom-feed): Load XML library if necessary. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-beamer.el (org-beamer-amend-header): Standardize the header cookie for the beamer extra stuff. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-beamer.el (org-beamer-amend-header): Put extra header last in header. 2010-07-19 David Maus <dmaus@ictsoc.de> * org-exp-blocks.el (org-export-blocks-format-ditaa) (org-export-blocks-format-dot): Remove text properties of body before calculating cache hash. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-latex.el (org-export-latex-tabular-environment): New option. (org-export-latex-tables): Use `org-export-latex-tabular-environment'. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-compat.el (org-version-check): New function. * org-indent.el (org-indent-mode): Check for exact emacs version. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-capture.el (org-capture-templates): Allow the template to come from a file or function call. (org-capture-place-entry): Get the template from file or function. 2010-07-19 David Maus <dmaus@ictsoc.de> * org-agenda.el (org-agenda-bulk-action): Don't create marker for position if target is entire file. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-autoload): Autoload a few more org-table functions. 2010-07-19 Eric Schulte <schulte.eric@gmail.com> * org.el (org-babel-load-languages): adding ob-mscgen 2010-07-19 Eric Schulte <schulte.eric@gmail.com> * org-latex.el (org-export-latex-tables): format string now matches options 2010-07-19 Eric Schulte <schulte.eric@gmail.com> * org.el (org-babel-load-languages): this variable controls which languages will be loaded by org-babel. It is customizable through the customize interface. 2010-07-19 Eric Schulte <schulte.eric@gmail.com> * org-latex.el (org-export-latex-format-image): updated number of arguments to allow for an optional short-name 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-indent.el (org-indent-mode): Refuse to turn on prior to Emacs 23.2 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-capture.el (org-capture-set-target-location): Store exact positions for file+regexp and file+function targets. (org-capture-place-entry, org-capture-place-item) (org-capture-place-table-line, org-capture-place-plain-text): Respect exact positions. (org-capture-finalize): Make sure we are at the beginning of a line when fixing the empty lines after the entry. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-entry-get-with-inheritance): New argument LITERAL-NIL. (org-entry-get): Pass `literal-nil' into `org-entry-get-with-inheritance'. (org-todo): React to nil values of the LOGGING property. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-default-notes-file): Update docstring 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-link-frame-setup): Use `org-gnus-no-new-news' as default. 2010-07-19 Eric Schulte <schulte.eric@gmail.com> * org-exp.el (org-export-attach-captions-and-attributes): adding a shortname attribute to caption strings under the symbol name org-caption-shortn. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-switchb): Renamed from `org-iswitchb'. Improve docstring. (org-iswitchb): New alias. (org-ido-switchb): Make alias point to `org-switchb'. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-capture.el (org-capture-fill-template): Respect time-of-day preference in template prompt. 2010-07-19 David Maus <dmaus@ictsoc.de> * org-feed.el (org-feed-unescape): Remove superfluous lambda. 2010-07-19 David Maus <dmaus@ictsoc.de> * org-wl.el (org-wl-disable-folder-check): New customization variable. (org-wl-open): Disable folder check depending on `org-wl-disable-folder-check'. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-capture.el (org-capture-set-target-location): Fix file+function interpretation. 2010-07-19 David Maus <dmaus@ictsoc.de> * org-feed.el (org-feed-parse-rss-entry): Unescape rss element content. 2010-07-19 David Maus <dmaus@ictsoc.de> * org-feed.el (xml-entity-alist): Declare variable `xml-entity-alist' for byte compiler. 2010-07-19 David Maus <dmaus@ictsoc.de> * org-feed.el (org-feed-unescape): New function. Unescape protected entities. (org-feed-parse-atom-entry): Use function for atom:content type text and html. 2010-07-19 David Maus <dmaus@ictsoc.de> * org-feed.el (org-feed-parse-rss-feed): Ignore case of rss element names. 2010-07-19 Bernt Hansen <bernt@norang.ca> * org.el (org-time-string-to-absolute): Ignore cyclic repeater when displaying items on todays agenda date. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-agenda.el (org-agenda-get-progress): Avoid reusing previous value of EXTRA. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-publish.el (org-publish-initialize-cache): Make timestamp directory, the entire path to it. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-handle-comments): Make sure to check for protection in the comment line, and not in the line after it. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-html.el (org-export-html-preprocess): Call org-format-latex, possibly with a protect-only argument. * org.el (org-format-latex): New argument PROTECT-ONLY. 2010-07-19 Eric Schulte <schulte.eric@gmail.com> * org-exp.el (org-export-handle-table-metalines): this function removes table specific meta-lines, now that we aren't wiping everything that looks remotely like a comment at the end of the export process we have to be sure to catch all of the specific lines in org-exp.el 2010-07-19 Nicolas Goaziou <n.goaziou@gmail.com> * org-exp.el: (org-export-select-backend-specific-text) Properly get rid of #+Backend and #+ATTR_Backend specifics to backends not matching the one we're exporting to. 2010-07-19 Eric Schulte <schulte.eric@gmail.com> * Makefile (lisp/org-install.el): replacing babel files in construction of org-install.el 2010-07-19 Eric Schulte <schulte.eric@gmail.com> * org-table.el (orgtbl-to-generic): added the :remove-newlines option which will strip newline characters from the text of table cells and replace then with "\n" 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-confirm-shell-link-function): (org-confirm-elisp-link-function): Limit the values that can be set by file variables. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-compute-latex-and-specials-regexp): Deal with string elements by discarding them. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-iswitchb): Make sure to use at least iswitchb. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-capture.el (org-capture-position-for-last-stored): org-capture-bookmark-last-stored-position): New functions. (org-capture-place-table-line): Better error catching. (org-capture-place-item): (org-capture-place-entry): (org-capture-place-plain-text): Call `org-capture-position-for-last-stored'. (org-capture-finalize): Just call `org-capture-bookmark-last-stored-position'. 2010-07-19 Eric Schulte <schulte.eric@gmail.com> * org-exp.el (org-export-mark-blockquote-verse-center): fixed small bug, now grabbing match data before overwritten by looking-at this fixes a problem with remainders of #+end_quote lines appearing in exported output 2010-07-19 David Maus <dmaus@ictsoc.de> * org.el (org-link-frame-setup): Add customization option for Wanderlust. 2010-07-19 Eric Schulte <schulte.eric@gmail.com> * org-latex.el (org-export-latex-fixed-width): now checking org-example rather than org-protected on verbatim export, because by default all ": " prefixed lines are marked protected 2010-07-19 Eric Schulte <schulte.eric@gmail.com> * org-latex.el (org-export-latex-fixed-width): check for protection before wrapping ": " lines as verbatim 2010-07-19 Eric Schulte <schulte.eric@gmail.com> * org-exp.el (org-export-handle-comments): check for protection before removing comments 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-entities.el (org-entities): Restructure the list. (org-entities-help): Turn the help output into a buffer in Org-mode, so that it becomes easier to find a symbol in the structure. (org-entities-create-table): Deal with new structure. 2010-07-19 David Maus <dmaus@ictsoc.de> * org-agenda.el (org-write-agenda): Use backquotes to expand `flet' at compile time. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-entry-properties): Make sure that standard property names are used even if the user has customized time keywords. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-macs.el (org-not-nil): Return the value if not interpreted as nil. * org.el (org-entry-get): (org-entry-get-with-inheritance): Interpret the value "nil" as nil for properties. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-switch-to-buffer-other-window): Return the buffer. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-macs.el (org-not-nil): New function. * org.el (org-block-todo-from-children-or-siblings-or-parent): Use `org-not-nil' to interpret a property value of nil. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-truely-invisible-p): New function. (org-beginning-of-line): Use `org-truely-invisible-p'. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-agenda.el (org-agenda-get-timestamps): No errors while getting TODO state. (org-agenda-highlight-todo): No error when no keyword has been matched. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-timestamp-change): New optional argument UPDOWN. Use this to identify calls from org-timestamp-up/down, so that we can skip by rounding minutes in this case. (org-timestamp-up): (org-timestamp-down): (org-timestamp-up-day): (org-timestamp-down-day): Call org-timestamp-change with the updown argument. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-agenda.el (org-agenda-action): Make `c' key call org-capture. * org-capture.el: New file. * org-compat.el (org-get-x-clipboard): Function moved here from remember.el. * org-mks.el: New file * org.el (org-set-regexps-and-options): Allow statistic cookies as part of complex headlines. (org-find-olp): New argument THIS-BUFFER. When set, assume that the OLP does not contain a file name. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-mode): Set `comment-start' instead of changing the syntax of the `#' character. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-format-source-code-or-example): Mark examples by a property. o * org-html.el (org-export-html-close-lists-maybe): Check if raw HTML stuff was actually made from an example 2010-07-19 Eric Schulte <schulte.eric@gmail.com> * Makefile (LISPF): let's not compile files that won't often be used. 2010-07-19 Bastien Guerry <bzg@altern.org> * org-latex.el: items are no longer skipped when their first line ends on a protected element. * org-list.el: protected environments looking like lists are not exported anymore. 2010-07-19 Eric Schulte <schulte.eric@gmail.com> * org-exp-blocks.el (org-export-blocks-preprocess): cleanup trailing newline after block 2010-07-19 Bastien Guerry <bzg@altern.org> * org-exp.el: comment regexp now matches documentation. No more protection check when deleting comments before export. 2010-07-19 Bastien Guerry <bzg@altern.org> * org-exp.el (org-export-preprocess-string): now using `org-export-handle-include-files-recurse' to resolve included files 2010-07-19 Bastien Guerry <bzg@altern.org> * org-agenda.el (org-agenda-get-deadlines): (org-agenda-get-scheduled): * org.el (org-time-string-to-seconds): For deadline and scheduled agenda display ignore the cyclic repeater when calculating how many days late the task is. If you have a weekly task and miss the date the agenda view will show more than a week late now instead of resetting on the cyclic repeating date. This makes it much more obvious when you missed a repeating task after the repeater. 2010-07-19 Bastien Guerry <bzg@altern.org> * org-exp.el (org-export-mark-blockquote-verse-center): Consider environments that end at eob. 2010-07-19 Mikael Fornius <mfo@abc.se> * org.el (org-raise-scripts): Do not fontify sub/superscripts of text with face `org-special-keyword'. Makes property keys as :LAST_REPEAT: display correctly. 2010-07-19 Mikael Fornius <mfo@abc.se> * org.el (org-at-property-p): Use save-match-data macro instead of let. 2010-07-19 Mikael Fornius <mfo@abc.se> * org.el (test): Removed unused test function. 2010-07-19 Eric Schulte <schulte.eric@gmail.com> * org-exp-blocks.el (org-export-blocks-preprocess): fixed typo 2010-07-19 Eric Schulte <schulte.eric@gmail.com> * org-exp-blocks.el (org-export-blocks-postblock-hook): adding documentation to and turning into a defcustom 2010-07-19 Eric Schulte <schulte.eric@gmail.com> * org-exp.el (org-get-file-contents): by un-setting prefix1 to "" instead of to nil we avoid errors when :prefix1 is defined, but prefix is not. 2010-07-19 Nicolas Goaziou <n.goaziou@gmail.com> * org-latex.el (org-export-latex-preprocess): Environments coming from latex backend specific instructions (#+LaTeX) are already protected and won't be treated as normal environments. 2010-07-19 Bastien Guerry <bzg@altern.org> * org-timer.el (org-timer-set-timer): Fix typo in the docstring. 2010-07-19 Bastien Guerry <bzg@altern.org> * org-timer.el (org-timer-set-timer): Use a prefix argument. See the docstring of the function. 2010-07-19 Bastien Guerry <bzg@altern.org> * org-timer.el (org-timer-set-timer): Fix bug about cancelling timers. 2010-07-19 David Maus <dmaus@ictsoc.de> * org-w3m.el (org-w3m-copy-for-org-mode) (org-w3m-get-next-link-start, org-w3m-get-prev-link-start): Get text property directly, not using macro `w3m-anchor'. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-emph-re): Document the match groups. 2010-07-19 Bernt Hansen <bernt@norang.ca> * org-clock.el (org-clock-in): Set `org-clock-clocking-in' to t before calling `org-clock-out', so that that function can know its call context. 2010-07-19 Bastien Guerry <bzg@altern.org> * org-timer.el (org-timer-default-timer): New variable. (org-timer-set-timer): Use the new variable. Also offer the possibility to replace the current timer by a new one. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-kill-note-or-show-branches): Hide subtree before exposing the headings. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-add-planning-info): Remove the empty line also if there is no whitespace at all in there. * org-table.el (org-table-align): Fix alignment of strings with invisible characters. 2010-07-19 David Maus <dmaus@ictsoc.de> * org.el (org-refile-cache-get): Return empty list of targets when cache was cleared. (org-clone-subtree-with-time-shift): Maybe create ID property in cloned subtrees. (org-clone-delete-id): New customization variable. (org-clone-subtree-with-time-shift): Use customization variable `org-clone-delete-id'. (org-clone-subtree-with-time-shift): Remove empty property drawer in cloned subtrees. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-refile-use-cache): New option. (org-refile-cache, org-refile-markers): New variable. (org-refile-marker, org-refile-cache-clear) (org-refile-cache-check-set, org-refile-cache-put) (org-refile-cache-get): New function. (org-get-refile-targets): Use the refile cache. * org-clock.el (org-clock-sum): Don't include running clock if the time block is wrong. 2010-07-19 John Wiegley <jwiegley@gmail.com> * org-clock.el (org-clock-clock-in, org-clock-in): Added parameter `start-time'. (org-clock-resolve-clock): Added parameter `clock-out-time'. If set, and resolve-to is a past time, then the clock out event occurs at `clock-out-time' rather than at `resolve-to'. In this case, `resolve-to' becomes the clock in time. (org-clock-jump-to-current-clock): Created new global command to reveal the current clock. (org-clock-resolve): Added new commands g/G and j/J, and a help window describing all commands and their meaning. (org-clock-resolve-expert): New customization variable. (org-find-open-clocks): Fixed a bug that caused discovered clocks not to match up with the currently active clock. (org-resolve-clocks): Changed the argument `also-non-dangling-p' to `only-dangling-p', since due to a bug this was the default behavior all along. 2010-07-19 David Maus <dmaus@ictsoc.de> * org-id.el (org-id-uuid): New function. Return string with random (version 4) UUID. (org-id-method): Make 'uuid the new default value. (org-id-new): Use `org-id-uuid' if call to uuidgen program does not return a UUID. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-latex.el (org-export-latex-format-image): Add support for multicolumn figures in LaTeX. 2010-07-19 David Maus <dmaus@ictsoc.de> * org.el (org-clone-subtree-with-time-shift): Remove ID property of original subtree in cloned subtrees. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-format-source-code-or-example): XEmacs compatibility. * org-latex.el (org-export-latex-tables): Accept comma in align string. * org-docbook.el (org-export-docbook-xslt-stylesheet): New option. (org-export-docbook-xslt-proc-command): Fix docstring. (org-export-docbook-xsl-fo-proc-command): Fix docstring. (org-export-as-docbook-pdf): Improve formatting of the xslt command. * org-exp.el (org-infile-export-plist): Check for XSLT setting. * org.el (org-file-contents): Improve error message. (org-set-regexps-and-options): Remove spaces at both ends. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-docbook.el (org-export-as-docbook-pdf): Improve formatting of the xslt command. 2010-07-19 Sebastian Rose <sebastian_rose@gmx.de> * org-publish.el (org-publish-cache): Use one big hashmap for each project defined in `org-publish-project-alist'. (initialize-files-alist): Function removed. (org-publish-validate-link): Function removed. (org-publish-get-base-files): Add variable `sitemap-requested' to avoid sorting where possible. (org-publish-get-files): Function removed. (org-publish-get-project-from-filename): Make independent of file list. (org-publish-file): New argument NO-CACHE. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-beginning-of-defun, org-end-of-defun): New functions. (org-mode): Install the `org-beginning-of-defun' and `org-end-of-defun' functions. (org-pretty-entities): New option. (org-toggle-pretty-entities): New command. (org-fontify-entities): New function. (org-startup-options): New keywords for pretty entities. (org-set-font-lock-defaults): Call the pretty entities function. * org-latex.el (org-export-latex-keywords-maybe): Protect the TODO markup. 2010-07-19 Mikael Fornius <mfo@abc.se> * org-habit.el (org-habit-build-graph): Help-echo date when mouse is over stars. 2010-07-19 Jan Bker <jan.boecker@jboecker.de> * org.el (org-file-apps): Improve docstring to reflect grouping matches 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-set-startup-visibility): Fix empty line display. * org-latex.el (org-export-latex-links): Use the formatting function of the link type, if it is available. * org-table.el (org-table-get-remote-range): Return to original buffer when retrieving remote reference. * org.el (org-display-inline-images): Do the entire buffer, not just the narrowed region. Clear the cache. (org-display-inline-images): Match mode file paths. 2010-07-19 David Maus <dmaus@ictsoc.de> * org-wl.el (org-wl-store-link-folder): Don't throw error when called on WL folder group. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-replace-escapes): Make sure the cdr is not nil. (org-read-date): Make `M-v' and `C-v' scroll the popup calendar. (org-mode): Revert comment syntax changes. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-sparse-tree): Make `C-c / t' search for all TODO keywords, and `C-c / T' for a specific one. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-mode): Fix comment syntax settings. * org-src.el (org-edit-src-allow-write-back-p): Define variable. * org.el (org-inline-image-overlays): New variable. (org-toggle-inline-images, org-display-inline-images) (org-remove-inline-images): New commands. (org-mode-map): Define a key for `org-toggle-inline-images'. 2010-07-19 David Maus <dmaus@ictsoc.de> * org-wl.el (org-wl-message-field): New function. Return content of header field in message entity. (org-wl-store-link): Call `org-wl-store-link-folder' or `org-wl-store-link-message' depending on major-mode. (org-wl-store-link-folder): New function. Store link to Wanderlust folder. (org-wl-store-link-message): New function. Store link to Wanderlust message. (org-wl-store-link-message): Store link to message while visiting message. (org-wl-open): Don't try to jump to message when opening a folder link. 2010-07-19 David Maus <dmaus@ictsoc.de> * org.el (org-replace-escapes): Avoid infinite loop when replace string contains escape sequence it replaces. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-crypt.el (org-crypt-key-for-heading): Use symmetric encryption when now key is set. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-table.el (org-table-recalculate-buffer-tables) (org-table-iterate-buffer-tables): New commands. * org.el (org-check-for-hidden): When there is a region, skip the check. 2010-07-19 Dan Davison <davison@stats.ox.ac.uk> * org-src.el (org-edit-src-code): allow-write-back-p had erroneously been omitted from let binding 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-agenda.el (org-sorting-choice): New sorting type alpha. (org-cmp-alpha): New defsubst. (org-em): New defsubst. (org-entries-lessp): Only compute needed comparisons. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-html.el (org-format-org-table-html): Test all columns for number content. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-latex.el (org-export-latex-treat-sub-super-char): Make sure parenthesis matching is consistent. * org-table.el (org-table-colgroup-line-p) (org-table-cookie-line-p): New functions. * org-exp.el (org-table-clean-before-export): Better tests for colgroup and cookie lines. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-agenda.el (org-agenda-goto): Push a mark before changing the position. * org-footnote.el (org-footnote): New group. (org-footnote-section) (org-footnote-tag-for-non-org-mode-files): Fix typos. * org-list.el (org-end-of-item-text-before-children): Also do the right thing at the end of a file. * org.el (org-set-packages-alist, org-get-packages-alist): New function. (org-export-latex-default-packages-alist) (org-export-latex-packages-alist): Add extra flag to each package, indicating if it should be used for snippets. (org-create-formula-image): Add the snippet argument. (org-splice-latex-header): New argument SNIPPET-P, pass it through to `org-latex-packages-to-string'. (org-latex-packages-to-string): New argument SNIPPET-P. * org-latex.el (org-export-latex-make-header): Add the snippet argument. * org-docbook.el (org-export-as-docbook): Implement ordered lists starting at some offset. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-link-types, org-open-at-point): Add doi links. * org-ascii.el (org-export-ascii-preprocess): Remove list startcounter cookies. * org-list.el (org-renumber-ordered-list): Respect counter start values. * org-latex.el (org-export-latex-lists): Accept ordered list item offset cookie. * org-html.el (org-export-as-html): Accept ordered list item offset cookie. * org-indent.el (org-indent-mode): Turn off `indent-tabs-mode' which messes up alignment of tags. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-clock.el (org-clock-cancel, org-clock-out): Make sure the modeline display is removed. * org-exp.el (org-export-format-drawer-function): Fix docstring. * org-agenda.el (org-agenda-refile): New optional argument NO-UPDATE. (org-agenda-refile): Call `org-agenda-redo' unless NO-UPDATE is set. (org-agenda-bulk-action): Call the refile command with updates suppressed - but arrange for `org-agenda-redo' to be called at the end. * org.el (org-mode): Make table mapping quiet. (org-table-map-tables): New optional argument QUIETLY. * org-ascii.el (org-export-ascii-preprocess): Make table mapping quiet. * org-html.el (org-export-as-html, org-html-level-start): Change XHTML IDs to not use dots. * org-exp.el (org-export-define-heading-targets): Change XHTML IDs to not use dots. * org-docbook.el (org-export-docbook-level-start): Change XHTML IDs to not use dots. * org-latex.el (org-export-as-latex): Make sure that the result buffer is in latex-mode. * org.el (org-shiftup-final-hook, org-shiftdown-final-hook) (org-shiftleft-final-hook, org-shiftright-final-hook): New hooks. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-table.el (org-table-justify-field-maybe): Make sure that inserting a value does not turn a line into a hline. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-clock.el (org-clock-sum): New argument HEADLINE-FILTER. (org-clock-sum): Add property to selected headlines. (org-dblock-write:clocktable): Make tags matcher. * org.el (org-set-autofill-regexps): XEmacs compatibility. * org-latex.el (org-export-latex-set-initial-vars): Allow "-" in latex class definitions * org.el (org-shiftup-hook, org-shiftdown-hook) (org-shiftleft-hook, org-shiftright-hook): New hooks. * org-entities.el (org-entities): Use \land and \lor for logical operators. * org.el (org-shiftmetaleft, org-shiftmetaright): Call the subtree indentation commands. (org-hidden-tree-error): New defsubst. (org-metaleft, org-metaright): Check for hidden stuff and throw an error. (org-check-for-hidden): New function. * org-list.el (org-item-re): New function. (org-at-item-p): Use `org-item-re'. (org-end-of-item-text-before-children): New function. (org-outdent-item, org-indent-item): Arrange for leaving the subtree alone. (org-outdent-item-tree, org-indent-item-tree): New argument NO-SUBTREE. (org-indent-item-tree): Use `org-end-of-item-text-before-children' to find the end for processing while ignoring the subtree. * org-publish.el (org-publish-sitemap-sort-alphabetically) (org-publish-sitemap-sort-folders) (org-publish-sitemap-sort-ignore-case): New options. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-publish.el (org-publish-compare-directory-files): Fix sorting. * org-compat.el (org-get-x-clipboard-compat): Use (featurep 'xemacs). * org-publish.el (org-publish-project-alist): Update docstring. (org-publish-file-title-cache): New variable. (org-publish-initialize-files-alist): Initialize `org-publish-initialize-files-alist' to nil. (org-publish-sort-directory-files): New function. (org-publish-projects): Access the new properties. (org-publish-find-title): Use the file title cache. (org-publish-find-title): Build the file title cache. (org-publish-get-base-files-1): Sort files. (org-publish-aux-preprocess): Do not throw an error when before the first headline. Allow an empty target, meaning to link just to the file. (org-publish-index-generate-theindex.inc): Check if there is actually a target and only then add it to the link. (org-publish-projects): Fix a remaining issue with the last commit * org-html.el (org-export-as-html): Treat verse as open/close paragraph. (org-export-html-close-lists-maybe): Allow to splice raw HTML into and out of lists. 2010-07-19 Dan Davison <davison@stats.ox.ac.uk> * org-src.el (org-edit-src-code): Allow the org-src edit buffer to be used in a read-only mode. (org-edit-src-code): Different message in read-only mode 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-src.el (org-edit-src-find-region-and-lang): Test for table.el as late as possible. * org-colview-xemacs.el: Make sure this file is never loaded into Emacs. Remove all tests for XEmacs. * org-colview.el: Make sure this file is never loaded into XEmacs. * org-agenda.el (org-highlight, org-unhighlight): Use direct overlay calls. * org.el (org-key): Apply the translations defined in `org-xemacs-key-equivalents'. * org-mouse.el (org-mode-hook): Use `org-defkey'. * org-compat.el (org-xemacs-key-equivalents): New constant. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-inlinetask.el (org-inlinetask-defaut-state): New option. (org-inlinetask-insert-task): Use `org-inlinetask-defaut-state'. Obey `org-odd-levels-only'. * org-compat.el (org-find-overlays): Use overlays-in/at. * org.el (org-remove-empty-overlays-at) (org-outline-overlay-data, org-hide-block-toggle) (org-format-latex, org-context): Use overlays-in/at. * org-src.el (org-edit-src-exit): Use overlays-in/at. * org-agenda.el (org-agenda-mark-clocking-task) (org-agenda-fontify-priorities, org-agenda-dim-blocked-tasks) (org-agenda-entry-text-hide) (org-agenda-fix-tags-filter-overlays-at) (org-agenda-bulk-remove-overlays): Use overlays-in/at. * org-compat.el (org-overlays-at): Function removed. (org-overlays-in): Function removed. 2010-07-19 Bastien Guerry <bzg@altern.org> * org-clock.el (org-clock-set-current): Just return the headline itself, strip the TODO keyword, the priority cookie and the tags. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-compat.el (org-xemacs-without-invisibility): New macro. (org-xemacs-without-invisibility): New macro. (org-indent-to-column, org-indent-line-to, org-move-to-column): Redefine using the macro `org-xemacs-without-invisibility'. * org.el (org-mode, org-org-menu): Use `add-to-invisibility-spec'. * org-table.el (orgtbl-mode): Use `add-to-invisibility-spec'. * org-compat.el (org-make-overlay, org-delete-overlay) (org-overlay-start, org-overlay-end, org-overlay-put) (org-overlay-get, org-overlay-move, org-overlay-buffer): Functions removed. (org-add-to-invisibility-spec): Function removed. * org-html.el (org-export-as-html-and-open): Add argument to kill-buffer. * org-habit.el (require): `calendar' is now required already by org.el on top level. * org-clock.el (require): `calendar' is now required already by org.el on top level. * org-agenda.el (require, org-timeline, org-agenda-list) (org-todo-list, org-agenda-to-appt): `calendar' is now required already by org.el on top level. * org.el (org-export-latex-fix-inputenc): Declare function. * org-agenda.el (org-agenda-goto-calendar): Do not bind obsolete variables. * org.el (calendar): Require calendar now on top level in org.el and define aliases to new variables when needed. (org-read-date, org-goto-calendar): Do not bind obsolete variables. * org-clock.el (org-clock-out, org-clock-cancel): Get rid of compilation warning, add comment that this cannot be done with `with-current-buffer'. * org-wl.el (org-wl-open): Use `with-current-buffer'. * org.el (overlay, org-remove-empty-overlays-at) (org-outline-overlay-data, org-set-outline-overlay-data) (org-show-block-all, org-hide-block-toggle) (org-highlight-new-match, org-remove-occur-highlights) (org-tags-overlay, org-fast-tag-selection, org-date-ovl) (org-read-date, org-read-date-display, org-eval-in-calendar) (org-format-latex, org-context) (org-speedbar-restriction-lock-overlay) (org-speedbar-set-agenda-restriction): Use the normal overlay API. * org-table.el (org-table-add-rectangle-overlay) (org-table-remove-rectangle-highlight) (org-table-overlay-coordinates) (org-table-toggle-coordinate-overlays): Use the normal overlay API. * org-src.el (org-edit-src-code, org-edit-fixed-width-region) (org-edit-src-exit, org-src-mode-configure-edit-buffer): Use the normal overlay API. * org-colview.el (org-columns-new-overlay) (org-columns-display-here, org-columns-remove-overlays) (org-columns-edit-value, org-columns-next-allowed-value) (org-columns-update): Use the normal overlay API. * org-clock.el (org-clock-out, org-clock-cancel) (org-clock-put-overlay, org-clock-remove-overlays): Use the normal overlay API. * org-agenda.el (org-agenda-mark-filtered-text) (org-agenda-mark-clocking-task, org-agenda-fontify-priorities) (org-agenda-dim-blocked-tasks, org-agenda-entry-text-show-here) (org-agenda-entry-text-hide) (org-agenda-restriction-lock-overlay) (org-agenda-set-restriction-lock) (org-agenda-filter-by-tag-hide-line) (org-agenda-fix-tags-filter-overlays-at) (org-agenda-filter-by-tag-show-all, org-hl) (org-agenda-goto-calendar, org-agenda-bulk-mark) (org-agenda-bulk-remove-overlays): Use the normal overlay API. * org-freemind.el (org-freemind-from-org-mode-node) (org-freemind-from-org-mode, ) (org-freemind-from-org-sparse-tree, org-freemind-to-org-mode): Use interactive-p instead of called-interactively, because this is backward compatible with older Emacsen I still support.. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-define-heading-targets): Fix bug in regexp finding ID and CUSTOM_ID properties. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-footnote.el (org-footnote-goto-previous-reference): Renamed from `org-footnote-goto-next-reference'. * org.el (org-auto-repeat-maybe): Only record LAST_REPEAT if org-log-repeat is non-nil, or if there is clocking data in the entry. * org-crypt.el (org-encrypt-entry): Improve mapping behavior. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-align-all-tags): New command. 2010-07-19 David Maus <dmaus@ictsoc.de> * org-wl.el (org-wl-link-remove-filter): New customizable variable. If non-nil, filter conditions are stripped when storing link to message in filter folder. (org-wl-shimbun-prefer-web-links): New customizable variable. If non-nil, links to shimbun messages are created as web links to message source. (org-wl-nntp-prefer-web-links): New customizable variable. If non-nil, links to nntp message are created as web links to gmane or googlegroups. (org-wl-namazu-default-index): New customizable variable. Directory of namazu search index that should be used as default when opening a link in a search folder. (org-wl-folder-types): New constant. Wanderlust folder type indicators. (org-wl-folder-type): New function. Return type of Wanderlust folder. (org-wl-store-link): Create web links for shimbun or nntp messages and strip filter conditions depending on customizable variables. (org-wl-open): Open namazu search folder for message when called with prefix. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-remove-if, org-remove-if-not): New functions. (org-open-file): Use internal remove-if functions. 2010-07-19 Jan Bcker <jan.boecker@jboecker.de> * org.el (org-file-apps-entry-match-against-dlink-p): new function. (org-file-apps-ex): remove variable. (org-open-file): Integrate org-file-apps-ex functionality back into org-file-apps, and decide whether to match a regexp against the link or the filename using org-file-apps-entry-uses-grouping-p. 2010-07-19 Jan Bcker <jan.boecker@jboecker.de> * org.el (org-file-apps-ex): new variable. (org-open-file): Before considering org-file-apps, first match the regexps from org-file-apps-ex against the whole link. See docstring of org-file-apps-ex. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-export-latex-default-packages-alist): Remove microtype package. (org-todo-repeat-to-state): New variable. (org-auto-repeat-maybe): Allow user-selected target states. (org-default-properties): Add the new property REPEAT_TO_STATE. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org-mobile.el (org-mobile-check-setup): Make sure that there is a binary to compute checksums. 2010-07-19 Carsten Dominik <carsten.dominik@gmail.com> * org.texi: Add macros to get plain quotes in PDF output. List additional contributors. (Capture): New section, replaces the section about remember. (Working With Source Code): New chapter, focused on documenting Org Babel. (Code evaluation security): New section. (MobileOrg): Document DropBox support. (TaskJuggler export): Document taskjuggler and Gantt chart support. (Special symbols): Show how to display UTF8 characters for entities. (Global TODO list): Clarify the use of the "M" key and the differences to the "m" key. (RSS Feeds): Mention Atom feeds as well. (Setting tags): Remove paragraph about `org-complete-tags-always-offer-all-agenda-tags'.
author Carsten Dominik <carsten.dominik@gmail.com>
date Mon, 19 Jul 2010 11:47:27 +0200
parents 446dbaf86e72
children 80192451ba34
comparison
equal deleted inserted replaced
109461:d898f8a84d48 109462:a150e8a14679
4 ;; Free Software Foundation, Inc. 4 ;; Free Software Foundation, Inc.
5 ;; 5 ;;
6 ;; Author: Carsten Dominik <carsten at orgmode dot org> 6 ;; Author: Carsten Dominik <carsten at orgmode dot org>
7 ;; Keywords: outlines, hypermedia, calendar, wp 7 ;; Keywords: outlines, hypermedia, calendar, wp
8 ;; Homepage: http://orgmode.org 8 ;; Homepage: http://orgmode.org
9 ;; Version: 6.35i 9 ;; Version: 7.01
10 ;; 10 ;;
11 ;; This file is part of GNU Emacs. 11 ;; This file is part of GNU Emacs.
12 ;; 12 ;;
13 ;; GNU Emacs is free software: you can redistribute it and/or modify 13 ;; GNU Emacs is free software: you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by 14 ;; it under the terms of the GNU General Public License as published by
74 (require 'cl) 74 (require 'cl)
75 (require 'gnus-sum)) 75 (require 'gnus-sum))
76 76
77 (require 'calendar) 77 (require 'calendar)
78 ;; Emacs 22 calendar compatibility: Make sure the new variables are available 78 ;; Emacs 22 calendar compatibility: Make sure the new variables are available
79 (unless (boundp 'calendar-view-holidays-initially-flag) 79 (when (fboundp 'defvaralias)
80 (defvaralias 'calendar-view-holidays-initially-flag 80 (unless (boundp 'calendar-view-holidays-initially-flag)
81 'view-calendar-holidays-initially)) 81 (defvaralias 'calendar-view-holidays-initially-flag
82 (unless (boundp 'calendar-view-diary-initially-flag) 82 'view-calendar-holidays-initially))
83 (defvaralias 'calendar-view-diary-initially-flag 83 (unless (boundp 'calendar-view-diary-initially-flag)
84 'view-diary-entries-initially)) 84 (defvaralias 'calendar-view-diary-initially-flag
85 (unless (boundp 'diary-fancy-buffer) 85 'view-diary-entries-initially))
86 (defvaralias 'diary-fancy-buffer 'fancy-diary-buffer)) 86 (unless (boundp 'diary-fancy-buffer)
87 (defvaralias 'diary-fancy-buffer 'fancy-diary-buffer)))
87 88
88 ;; For XEmacs, noutline is not yet provided by outline.el, so arrange for 89 ;; For XEmacs, noutline is not yet provided by outline.el, so arrange for
89 ;; the file noutline.el being loaded. 90 ;; the file noutline.el being loaded.
90 (if (featurep 'xemacs) (condition-case nil (require 'noutline))) 91 (if (featurep 'xemacs) (condition-case nil (require 'noutline)))
91 ;; We require noutline, which might be provided in outline.el 92 ;; We require noutline, which might be provided in outline.el
92 (require 'outline) (require 'noutline) 93 (require 'outline) (require 'noutline)
93 ;; Other stuff we need. 94 ;; Other stuff we need.
94 (require 'time-date) 95 (require 'time-date)
95 (unless (fboundp 'time-subtract) (defalias 'time-subtract 'subtract-time)) 96 (unless (fboundp 'time-subtract) (defalias 'time-subtract 'subtract-time))
96 (require 'easymenu) 97 (require 'easymenu)
98 (require 'overlay)
97 99
98 (require 'org-macs) 100 (require 'org-macs)
99 (require 'org-entities) 101 (require 'org-entities)
100 (require 'org-compat) 102 (require 'org-compat)
101 (require 'org-faces) 103 (require 'org-faces)
102 (require 'org-list) 104 (require 'org-list)
103 (require 'org-src) 105 (require 'org-src)
104 (require 'org-footnote) 106 (require 'org-footnote)
105 107
108 ;; babel
109 (require 'ob)
110 (require 'ob-table)
111 (require 'ob-lob)
112 (require 'ob-ref)
113 (require 'ob-tangle)
114 (require 'ob-comint)
115 (require 'ob-keys)
116
117 ;; load languages based on value of `org-babel-load-languages'
118 (defvar org-babel-load-languages)
119 ;;;###autoload
120 (defun org-babel-do-load-languages (sym value)
121 "Load the languages defined in `org-babel-load-languages'."
122 (set-default sym value)
123 (mapc (lambda (pair)
124 (let ((active (cdr pair)) (lang (symbol-name (car pair))))
125 (if active
126 (progn
127 (require (intern (concat "ob-" lang))))
128 (progn
129 (funcall 'fmakunbound
130 (intern (concat "org-babel-execute:" lang)))
131 (funcall 'fmakunbound
132 (intern (concat "org-babel-expand-body:" lang)))))))
133 org-babel-load-languages))
134
135 (defcustom org-babel-load-languages '((emacs-lisp . t))
136 "Languages which can be evaluated in Org-mode buffers.
137 This list can be used to load support for any of the languages
138 below, note that each language will depend on a different set of
139 system executables and/or Emacs modes. When a language is
140 \"loaded\", then code blocks in that language can be evaluated
141 with `org-babel-execute-src-block' bound by default to C-c
142 C-c (note the `org-babel-no-eval-on-ctrl-c-ctrl-c' variable can
143 be set to remove code block evaluation from the C-c C-c
144 keybinding. By default only Emacs Lisp (which has no
145 requirements) is loaded."
146 :group 'org-babel
147 :set 'org-babel-do-load-languages
148 :type '(alist :tag "Babel Languages"
149 :key-type
150 (choice
151 (const :tag "C" C)
152 (const :tag "R" R)
153 (const :tag "Asymptote" asymptote)
154 (const :tag "Clojure" clojure)
155 (const :tag "CSS" css)
156 (const :tag "Ditaa" ditaa)
157 (const :tag "Dot" dot)
158 (const :tag "Emacs Lisp" emacs-lisp)
159 (const :tag "Gnuplot" gnuplot)
160 (const :tag "Haskell" haskell)
161 (const :tag "Latex" latex)
162 (const :tag "Matlab" matlab)
163 (const :tag "Mscgen" mscgen)
164 (const :tag "Ocaml" ocaml)
165 (const :tag "Octave" octave)
166 (const :tag "Perl" perl)
167 (const :tag "Python" python)
168 (const :tag "Ruby" ruby)
169 (const :tag "Sass" sass)
170 (const :tag "Screen" screen)
171 (const :tag "Shell Script" sh)
172 (const :tag "Sql" sql)
173 (const :tag "Sqlite" sqlite))
174 :value-type (boolean :tag "Activate" :value t)))
175
106 ;;;; Customization variables 176 ;;;; Customization variables
177 (defcustom org-clone-delete-id nil
178 "Remove ID property of clones of a subtree.
179 When non-nil, clones of a subtree don't inherit the ID property.
180 Otherwise they inherit the ID property with a new unique
181 identifier."
182 :type 'boolean
183 :group 'org-id)
107 184
108 ;;; Version 185 ;;; Version
109 186
110 (defconst org-version "6.35i" 187 (defconst org-version "7.01"
111 "The version number of the file org.el.") 188 "The version number of the file org.el.")
112 189
113 (defun org-version (&optional here) 190 (defun org-version (&optional here)
114 "Show the org-mode version in the echo area. 191 "Show the org-mode version in the echo area.
115 With prefix arg HERE, insert it at point." 192 With prefix arg HERE, insert it at point."
237 314
238 (const :tag "C jira: Add a jira:ticket protocol to Org-mode" org-jira) 315 (const :tag "C jira: Add a jira:ticket protocol to Org-mode" org-jira)
239 (const :tag "C learn: SuperMemo's incremental learning algorithm" org-learn) 316 (const :tag "C learn: SuperMemo's incremental learning algorithm" org-learn)
240 (const :tag "C mairix: Hook mairix search into Org-mode for different MUAs" org-mairix) 317 (const :tag "C mairix: Hook mairix search into Org-mode for different MUAs" org-mairix)
241 (const :tag "C mac-iCal Imports events from iCal.app to the Emacs diary" org-mac-iCal) 318 (const :tag "C mac-iCal Imports events from iCal.app to the Emacs diary" org-mac-iCal)
319 (const :tag "C mac-link-grabber Grab links and URLs from various Mac applications" org-mac-link-grabber)
242 (const :tag "C man: Support for links to manpages in Org-mode" org-man) 320 (const :tag "C man: Support for links to manpages in Org-mode" org-man)
243 (const :tag "C mtags: Support for muse-like tags" org-mtags) 321 (const :tag "C mtags: Support for muse-like tags" org-mtags)
244 (const :tag "C panel: Simple routines for us with bad memory" org-panel) 322 (const :tag "C panel: Simple routines for us with bad memory" org-panel)
245 (const :tag "C registry: A registry for Org-mode links" org-registry) 323 (const :tag "C registry: A registry for Org-mode links" org-registry)
246 (const :tag "C org2rem: Convert org appointments into reminders" org2rem) 324 (const :tag "C org2rem: Convert org appointments into reminders" org2rem)
248 (const :tag "C secretary: Team management with org-mode" org-secretary) 326 (const :tag "C secretary: Team management with org-mode" org-secretary)
249 (const :tag "C special-blocks: Turn blocks into LaTeX envs and HTML divs" org-special-blocks) 327 (const :tag "C special-blocks: Turn blocks into LaTeX envs and HTML divs" org-special-blocks)
250 (const :tag "C sqlinsert: Convert Org-mode tables to SQL insertions" orgtbl-sqlinsert) 328 (const :tag "C sqlinsert: Convert Org-mode tables to SQL insertions" orgtbl-sqlinsert)
251 (const :tag "C toc: Table of contents for Org-mode buffer" org-toc) 329 (const :tag "C toc: Table of contents for Org-mode buffer" org-toc)
252 (const :tag "C track: Keep up with Org-mode development" org-track) 330 (const :tag "C track: Keep up with Org-mode development" org-track)
331 (const :tag "C TaskJuggler: Export tasks to a TaskJuggler project" org-taskjuggler)
253 (repeat :tag "External packages" :inline t (symbol :tag "Package")))) 332 (repeat :tag "External packages" :inline t (symbol :tag "Package"))))
254 333
255 (defcustom org-support-shift-select nil 334 (defcustom org-support-shift-select nil
256 "Non-nil means make shift-cursor commands select text when possible. 335 "Non-nil means make shift-cursor commands select text when possible.
257 336
258 In Emacs 23, when `shift-select-mode' is on, shifted cursor keys start 337 In Emacs 23, when `shift-select-mode' is on, shifted cursor keys start
259 selecting a region, or enlarge thusly regions started in this way. 338 selecting a region, or enlarge regions started in this way.
260 In Org-mode, in special contexts, these same keys are used for other 339 In Org-mode, in special contexts, these same keys are used for other
261 purposes, important enough to compete with shift selection. Org tries 340 purposes, important enough to compete with shift selection. Org tries
262 to balance these needs by supporting `shift-select-mode' outside these 341 to balance these needs by supporting `shift-select-mode' outside these
263 special contexts, under control of this variable. 342 special contexts, under control of this variable.
264 343
333 :group 'org-structure 412 :group 'org-structure
334 :type '(choice 413 :type '(choice
335 (const :tag "Not" nil) 414 (const :tag "Not" nil)
336 (const :tag "Globally (slow on startup in large files)" t))) 415 (const :tag "Globally (slow on startup in large files)" t)))
337 416
417 (defcustom org-use-sub-superscripts t
418 "Non-nil means interpret \"_\" and \"^\" for export.
419 When this option is turned on, you can use TeX-like syntax for sub- and
420 superscripts. Several characters after \"_\" or \"^\" will be
421 considered as a single item - so grouping with {} is normally not
422 needed. For example, the following things will be parsed as single
423 sub- or superscripts.
424
425 10^24 or 10^tau several digits will be considered 1 item.
426 10^-12 or 10^-tau a leading sign with digits or a word
427 x^2-y^3 will be read as x^2 - y^3, because items are
428 terminated by almost any nonword/nondigit char.
429 x_{i^2} or x^(2-i) braces or parenthesis do grouping.
430
431 Still, ambiguity is possible - so when in doubt use {} to enclose the
432 sub/superscript. If you set this variable to the symbol `{}',
433 the braces are *required* in order to trigger interpretations as
434 sub/superscript. This can be helpful in documents that need \"_\"
435 frequently in plain text.
436
437 Not all export backends support this, but HTML does.
438
439 This option can also be set with the +OPTIONS line, e.g. \"^:nil\"."
440 :group 'org-startup
441 :group 'org-export-translation
442 :type '(choice
443 (const :tag "Always interpret" t)
444 (const :tag "Only with braces" {})
445 (const :tag "Never interpret" nil)))
446
447 (if (fboundp 'defvaralias)
448 (defvaralias 'org-export-with-sub-superscripts 'org-use-sub-superscripts))
449
450
338 (defcustom org-startup-with-beamer-mode nil 451 (defcustom org-startup-with-beamer-mode nil
339 "Non-nil means turn on `org-beamer-mode' on startup. 452 "Non-nil means turn on `org-beamer-mode' on startup.
340 This can also be configured on a per-file basis by adding one of 453 This can also be configured on a per-file basis by adding one of
341 the following lines anywhere in the buffer: 454 the following lines anywhere in the buffer:
342 455
380 become effective." 493 become effective."
381 :group 'org-startup 494 :group 'org-startup
382 :type 'boolean) 495 :type 'boolean)
383 496
384 (defcustom org-use-extra-keys nil 497 (defcustom org-use-extra-keys nil
385 "Non-nil means use extra key sequence definitions for certain 498 "Non-nil means use extra key sequence definitions for certain commands.
386 commands. This happens automatically if you run XEmacs or if 499 This happens automatically if you run XEmacs or if `window-system'
387 window-system is nil. This variable lets you do the same 500 is nil. This variable lets you do the same manually. You must
388 manually. You must set it before loading org. 501 set it before loading org.
389 502
390 Example: on Carbon Emacs 22 running graphically, with an external 503 Example: on Carbon Emacs 22 running graphically, with an external
391 keyboard on a Powerbook, the default way of setting M-left might 504 keyboard on a Powerbook, the default way of setting M-left might
392 not work for either Alt or ESC. Setting this variable will make 505 not work for either Alt or ESC. Setting this variable will make
393 it work for ESC." 506 it work for ESC."
414 :group 'org-startup 527 :group 'org-startup
415 :type 'alist) 528 :type 'alist)
416 529
417 (defun org-key (key) 530 (defun org-key (key)
418 "Select key according to `org-replace-disputed-keys' and `org-disputed-keys'. 531 "Select key according to `org-replace-disputed-keys' and `org-disputed-keys'.
419 Or return the original if not disputed." 532 Or return the original if not disputed.
420 (if org-replace-disputed-keys 533 Also apply the translations defined in `org-xemacs-key-equivalents'."
421 (let* ((nkey (key-description key)) 534 (when org-replace-disputed-keys
422 (x (org-find-if (lambda (x) 535 (let* ((nkey (key-description key))
423 (equal (key-description (car x)) nkey)) 536 (x (org-find-if (lambda (x)
424 org-disputed-keys))) 537 (equal (key-description (car x)) nkey))
425 (if x (cdr x) key)) 538 org-disputed-keys)))
426 key)) 539 (setq key (if x (cdr x) key))))
540 (when (featurep 'xemacs)
541 (setq key (or (cdr (assoc key org-xemacs-key-equivalents)) key)))
542 key)
427 543
428 (defun org-find-if (predicate seq) 544 (defun org-find-if (predicate seq)
429 (catch 'exit 545 (catch 'exit
430 (while seq 546 (while seq
431 (if (funcall predicate (car seq)) 547 (if (funcall predicate (car seq))
634 be assigned to `self-insert-command' in the global map. 750 be assigned to `self-insert-command' in the global map.
635 The cdr is either a command to be called interactively, a function 751 The cdr is either a command to be called interactively, a function
636 to be called, or a form to be evaluated. 752 to be called, or a form to be evaluated.
637 An entry that is just a list with a single string will be interpreted 753 An entry that is just a list with a single string will be interpreted
638 as a descriptive headline that will be added when listing the speed 754 as a descriptive headline that will be added when listing the speed
639 copmmands in the Help buffer using the `?' speed command." 755 commands in the Help buffer using the `?' speed command."
640 :group 'org-structure 756 :group 'org-structure
641 :type '(repeat :value ("k" . ignore) 757 :type '(repeat :value ("k" . ignore)
642 (choice :value ("k" . ignore) 758 (choice :value ("k" . ignore)
643 (list :tag "Descriptive Headline" (string :tag "Headline")) 759 (list :tag "Descriptive Headline" (string :tag "Headline"))
644 (cons :tag "Letter and Command" 760 (cons :tag "Letter and Command"
700 :type 'boolean) 816 :type 'boolean)
701 817
702 (defcustom org-cycle-global-at-bob nil 818 (defcustom org-cycle-global-at-bob nil
703 "Cycle globally if cursor is at beginning of buffer and not at a headline. 819 "Cycle globally if cursor is at beginning of buffer and not at a headline.
704 This makes it possible to do global cycling without having to use S-TAB or 820 This makes it possible to do global cycling without having to use S-TAB or
705 C-u TAB. For this special case to work, the first line of the buffer 821 \\[universal-argument] TAB. For this special case to work, the first line \
822 of the buffer
706 must not be a headline - it may be empty or some other text. When used in 823 must not be a headline - it may be empty or some other text. When used in
707 this way, `org-cycle-hook' is disables temporarily, to make sure the 824 this way, `org-cycle-hook' is disables temporarily, to make sure the
708 cursor stays at the beginning of the buffer. 825 cursor stays at the beginning of the buffer.
709 When this option is nil, don't do anything special at the beginning 826 When this option is nil, don't do anything special at the beginning
710 of the buffer." 827 of the buffer."
714 (defcustom org-cycle-level-after-item/entry-creation t 831 (defcustom org-cycle-level-after-item/entry-creation t
715 "Non-nil means cycle entry level or item indentation in new empty entries. 832 "Non-nil means cycle entry level or item indentation in new empty entries.
716 833
717 When the cursor is at the end of an empty headline, i.e with only stars 834 When the cursor is at the end of an empty headline, i.e with only stars
718 and maybe a TODO keyword, TAB will then switch the entry to become a child, 835 and maybe a TODO keyword, TAB will then switch the entry to become a child,
719 and then all possible anchestor states, before returning to the original state. 836 and then all possible ancestor states, before returning to the original state.
720 This makes data entry extremely fast: M-RET to create a new headline, 837 This makes data entry extremely fast: M-RET to create a new headline,
721 on TAB to make it a child, two or more tabs to make it a (grand-)uncle. 838 on TAB to make it a child, two or more tabs to make it a (grand-)uncle.
722 839
723 When the cursor is at the end of an empty plain list item, one TAB will 840 When the cursor is at the end of an empty plain list item, one TAB will
724 make it a subitem, two or more tabs will back up to make this an item 841 make it a subitem, two or more tabs will back up to make this an item
877 - When in the middle of the headline text, kill the headline up to the tags. 994 - When in the middle of the headline text, kill the headline up to the tags.
878 - When after the headline text, kill the tags." 995 - When after the headline text, kill the tags."
879 :group 'org-edit-structure 996 :group 'org-edit-structure
880 :type 'boolean) 997 :type 'boolean)
881 998
999 (defcustom org-ctrl-k-protect-subtree nil
1000 "Non-nil means, do not delete a hidden subtree with C-k.
1001 When set to the symbol `error', simply throw an error when C-k is
1002 used to kill (part-of) a headline that has hidden text behind it.
1003 Any other non-nil value will result in a query to the user, if it is
1004 OK to kill that hidden subtree. When nil, kill without remorse."
1005 :group 'org-edit-structure
1006 :type '(choice
1007 (const :tag "Do not protect hidden subtrees" nil)
1008 (const :tag "Protect hidden subtrees with a security query" t)
1009 (const :tag "Never kill a hidden subtree with C-k" error)))
1010
882 (defcustom org-yank-folded-subtrees t 1011 (defcustom org-yank-folded-subtrees t
883 "Non-nil means when yanking subtrees, fold them. 1012 "Non-nil means when yanking subtrees, fold them.
884 If the kill is a single subtree, or a sequence of subtrees, i.e. if 1013 If the kill is a single subtree, or a sequence of subtrees, i.e. if
885 it starts with a heading and all other headings in it are either children 1014 it starts with a heading and all other headings in it are either children
886 or siblings, then fold all the subtrees. However, do this only if no 1015 or siblings, then fold all the subtrees. However, do this only if no
960 When nil, such lines will be treated like ordinary lines. 1089 When nil, such lines will be treated like ordinary lines.
961 See also the QUOTE keyword." 1090 See also the QUOTE keyword."
962 :group 'org-edit-structure 1091 :group 'org-edit-structure
963 :type 'boolean) 1092 :type 'boolean)
964 1093
965
966 (defcustom org-goto-auto-isearch t 1094 (defcustom org-goto-auto-isearch t
967 "Non-nil means typing characters in org-goto starts incremental search." 1095 "Non-nil means typing characters in `org-goto' starts incremental search."
968 :group 'org-edit-structure 1096 :group 'org-edit-structure
969 :type 'boolean) 1097 :type 'boolean)
970 1098
971 (defgroup org-sparse-trees nil 1099 (defgroup org-sparse-trees nil
972 "Options concerning sparse trees in Org-mode." 1100 "Options concerning sparse trees in Org-mode."
1148 (const :tag "Tags" tag) 1276 (const :tag "Tags" tag)
1149 (const :tag "Timestamps" date) 1277 (const :tag "Timestamps" date)
1150 (const :tag "Footnotes" footnote))) 1278 (const :tag "Footnotes" footnote)))
1151 1279
1152 (defcustom org-make-link-description-function nil 1280 (defcustom org-make-link-description-function nil
1153 "Function to use to generate link descriptions from links. If 1281 "Function to use to generate link descriptions from links.
1154 nil the link location will be used. This function must take two 1282 If nil the link location will be used. This function must take
1155 parameters; the first is the link and the second the description 1283 two parameters; the first is the link and the second the
1156 org-insert-link has generated, and should return the description 1284 description `org-insert-link' has generated, and should return the
1157 to use." 1285 description to use."
1158 :group 'org-link 1286 :group 'org-link
1159 :type 'function) 1287 :type 'function)
1160 1288
1161 (defgroup org-link-store nil 1289 (defgroup org-link-store nil
1162 "Options concerning storing links in Org-mode." 1290 "Options concerning storing links in Org-mode."
1289 implementation is bad." 1417 implementation is bad."
1290 :group 'org-link-follow 1418 :group 'org-link-follow
1291 :type 'boolean) 1419 :type 'boolean)
1292 1420
1293 (defcustom org-return-follows-link nil 1421 (defcustom org-return-follows-link nil
1294 "Non-nil means on links RET will follow the link. 1422 "Non-nil means on links RET will follow the link."
1295 Needs to be set before org.el is loaded."
1296 :group 'org-link-follow 1423 :group 'org-link-follow
1297 :type 'boolean) 1424 :type 'boolean)
1298 1425
1299 (defcustom org-mouse-1-follows-link 1426 (defcustom org-mouse-1-follows-link
1300 (if (boundp 'mouse-1-click-follows-link) mouse-1-click-follows-link t) 1427 (if (boundp 'mouse-1-click-follows-link) mouse-1-click-follows-link t)
1303 Needs to be set before org.el is loaded." 1430 Needs to be set before org.el is loaded."
1304 :group 'org-link-follow 1431 :group 'org-link-follow
1305 :type 'boolean) 1432 :type 'boolean)
1306 1433
1307 (defcustom org-mark-ring-length 4 1434 (defcustom org-mark-ring-length 4
1308 "Number of different positions to be recorded in the ring 1435 "Number of different positions to be recorded in the ring.
1309 Changing this requires a restart of Emacs to work correctly." 1436 Changing this requires a restart of Emacs to work correctly."
1310 :group 'org-link-follow 1437 :group 'org-link-follow
1311 :type 'integer) 1438 :type 'integer)
1312 1439
1313 (defcustom org-link-frame-setup 1440 (defcustom org-link-frame-setup
1314 '((vm . vm-visit-folder-other-frame) 1441 '((vm . vm-visit-folder-other-frame)
1315 (gnus . gnus-other-frame) 1442 (gnus . org-gnus-no-new-news)
1316 (file . find-file-other-window)) 1443 (file . find-file-other-window)
1444 (wl . wl-other-frame))
1317 "Setup the frame configuration for following links. 1445 "Setup the frame configuration for following links.
1318 When following a link with Emacs, it may often be useful to display 1446 When following a link with Emacs, it may often be useful to display
1319 this link in another window or frame. This variable can be used to 1447 this link in another window or frame. This variable can be used to
1320 set this up for the different types of links. 1448 set this up for the different types of links.
1321 For VM, use any of 1449 For VM, use any of
1327 `org-gnus-no-new-news' 1455 `org-gnus-no-new-news'
1328 For FILE, use any of 1456 For FILE, use any of
1329 `find-file' 1457 `find-file'
1330 `find-file-other-window' 1458 `find-file-other-window'
1331 `find-file-other-frame' 1459 `find-file-other-frame'
1460 For Wanderlust use any of
1461 `wl'
1462 `wl-other-frame'
1332 For the calendar, use the variable `calendar-setup'. 1463 For the calendar, use the variable `calendar-setup'.
1333 For BBDB, it is currently only possible to display the matches in 1464 For BBDB, it is currently only possible to display the matches in
1334 another window." 1465 another window."
1335 :group 'org-link-follow 1466 :group 'org-link-follow
1336 :type '(list 1467 :type '(list
1346 (const org-gnus-no-new-news))) 1477 (const org-gnus-no-new-news)))
1347 (cons (const file) 1478 (cons (const file)
1348 (choice 1479 (choice
1349 (const find-file) 1480 (const find-file)
1350 (const find-file-other-window) 1481 (const find-file-other-window)
1351 (const find-file-other-frame))))) 1482 (const find-file-other-frame)))
1483 (cons (const wl)
1484 (choice
1485 (const wl)
1486 (const wl-other-frame)))))
1352 1487
1353 (defcustom org-display-internal-link-with-indirect-buffer nil 1488 (defcustom org-display-internal-link-with-indirect-buffer nil
1354 "Non-nil means use indirect buffer to display infile links. 1489 "Non-nil means use indirect buffer to display infile links.
1355 Activating internal links (from one location in a file to another location 1490 Activating internal links (from one location in a file to another location
1356 in the same file) normally just jumps to the location. When the link is 1491 in the same file) normally just jumps to the location. When the link is
1357 activated with a C-u prefix (or with mouse-3), the link is displayed in 1492 activated with a \\[universal-argument] prefix (or with mouse-3), the link \
1493 is displayed in
1358 another window. When this option is set, the other window actually displays 1494 another window. When this option is set, the other window actually displays
1359 an indirect buffer clone of the current buffer, to avoid any visibility 1495 an indirect buffer clone of the current buffer, to avoid any visibility
1360 changes to the current buffer." 1496 changes to the current buffer."
1361 :group 'org-link-follow 1497 :group 'org-link-follow
1362 :type 'boolean) 1498 :type 'boolean)
1377 :group 'org-link-follow 1513 :group 'org-link-follow
1378 :type 'boolean) 1514 :type 'boolean)
1379 1515
1380 (defcustom org-link-mailto-program '(browse-url "mailto:%a?subject=%s") 1516 (defcustom org-link-mailto-program '(browse-url "mailto:%a?subject=%s")
1381 "Function and arguments to call for following mailto links. 1517 "Function and arguments to call for following mailto links.
1382 This is a list with the first element being a lisp function, and the 1518 This is a list with the first element being a Lisp function, and the
1383 remaining elements being arguments to the function. In string arguments, 1519 remaining elements being arguments to the function. In string arguments,
1384 %a will be replaced by the address, and %s will be replaced by the subject 1520 %a will be replaced by the address, and %s will be replaced by the subject
1385 if one was given like in <mailto:arthur@galaxy.org::this subject>." 1521 if one was given like in <mailto:arthur@galaxy.org::this subject>."
1386 :group 'org-link-follow 1522 :group 'org-link-follow
1387 :type '(choice 1523 :type '(choice
1404 :group 'org-link-follow 1540 :group 'org-link-follow
1405 :type '(choice 1541 :type '(choice
1406 (const :tag "with yes-or-no (safer)" yes-or-no-p) 1542 (const :tag "with yes-or-no (safer)" yes-or-no-p)
1407 (const :tag "with y-or-n (faster)" y-or-n-p) 1543 (const :tag "with y-or-n (faster)" y-or-n-p)
1408 (const :tag "no confirmation (dangerous)" nil))) 1544 (const :tag "no confirmation (dangerous)" nil)))
1545 (put 'org-confirm-shell-link-function
1546 'safe-local-variable
1547 '(lambda (x) (member x '(yes-or-no-p y-or-n-p))))
1409 1548
1410 (defcustom org-confirm-elisp-link-function 'yes-or-no-p 1549 (defcustom org-confirm-elisp-link-function 'yes-or-no-p
1411 "Non-nil means ask for confirmation before executing Emacs Lisp links. 1550 "Non-nil means ask for confirmation before executing Emacs Lisp links.
1412 Elisp links can be dangerous: just think about a link 1551 Elisp links can be dangerous: just think about a link
1413 1552
1421 :group 'org-link-follow 1560 :group 'org-link-follow
1422 :type '(choice 1561 :type '(choice
1423 (const :tag "with yes-or-no (safer)" yes-or-no-p) 1562 (const :tag "with yes-or-no (safer)" yes-or-no-p)
1424 (const :tag "with y-or-n (faster)" y-or-n-p) 1563 (const :tag "with y-or-n (faster)" y-or-n-p)
1425 (const :tag "no confirmation (dangerous)" nil))) 1564 (const :tag "no confirmation (dangerous)" nil)))
1565 (put 'org-confirm-shell-link-function
1566 'safe-local-variable
1567 '(lambda (x) (member x '(yes-or-no-p y-or-n-p))))
1426 1568
1427 (defconst org-file-apps-defaults-gnu 1569 (defconst org-file-apps-defaults-gnu
1428 '((remote . emacs) 1570 '((remote . emacs)
1429 (system . mailcap) 1571 (system . mailcap)
1430 (t . mailcap)) 1572 (t . mailcap))
1472 Org-mode uses system defaults for different file types, but 1614 Org-mode uses system defaults for different file types, but
1473 you can use this variable to set the application for a given file 1615 you can use this variable to set the application for a given file
1474 extension. The entries in this list are cons cells where the car identifies 1616 extension. The entries in this list are cons cells where the car identifies
1475 files and the cdr the corresponding command. Possible values for the 1617 files and the cdr the corresponding command. Possible values for the
1476 file identifier are 1618 file identifier are
1477 \"regex\" Regular expression matched against the file: link. For 1619 \"string\" A string as a file identifier can be interpreted in different
1478 backward compatibility, this can also be a string with only 1620 ways, depending on its contents:
1479 alphanumeric characters, which is then interpreted as an 1621
1480 extension. 1622 - Alphanumeric characters only:
1623 Match links with this file extension.
1624 Example: (\"pdf\" . \"evince %s\")
1625 to open PDFs with evince.
1626
1627 - Regular expression: Match links where the
1628 filename matches the regexp. If you want to
1629 use groups here, use shy groups.
1630
1631 Example: (\"\\.x?html\\'\" . \"firefox %s\")
1632 (\"\\(?:xhtml\\|html\\)\" . \"firefox %s\")
1633 to open *.html and *.xhtml with firefox.
1634
1635 - Regular expression which contains (non-shy) groups:
1636 Match links where the whole link, including \"::\", and
1637 anything after that, matches the regexp.
1638 In a custom command string, %1, %2, etc. are replaced with
1639 the parts of the link that were matched by the groups.
1640 For backwards compatibility, if a command string is given
1641 that does not use any of the group matches, this case is
1642 handled identically to the second one (i.e. match against
1643 file name only).
1644 In a custom lisp form, you can access the group matches with
1645 (match-string n link).
1646
1647 Example: (\"\\.pdf::\\(\\d+\\)\\'\" . \"evince -p %1 %s\")
1648 to open [[file:document.pdf::5]] with evince at page 5.
1649
1481 `directory' Matches a directory 1650 `directory' Matches a directory
1482 `remote' Matches a remote file, accessible through tramp or efs. 1651 `remote' Matches a remote file, accessible through tramp or efs.
1483 Remote files most likely should be visited through Emacs 1652 Remote files most likely should be visited through Emacs
1484 because external applications cannot handle such paths. 1653 because external applications cannot handle such paths.
1485 `auto-mode' Matches files that are matched by any entry in `auto-mode-alist', 1654 `auto-mode' Matches files that are matched by any entry in `auto-mode-alist',
1489 (\"html\" . default) to the list as well. 1658 (\"html\" . default) to the list as well.
1490 t Default for files not matched by any of the other options. 1659 t Default for files not matched by any of the other options.
1491 `system' The system command to open files, like `open' on Windows 1660 `system' The system command to open files, like `open' on Windows
1492 and Mac OS X, and mailcap under GNU/Linux. This is the command 1661 and Mac OS X, and mailcap under GNU/Linux. This is the command
1493 that will be selected if you call `C-c C-o' with a double 1662 that will be selected if you call `C-c C-o' with a double
1494 `C-u C-u' prefix. 1663 \\[universal-argument] \\[universal-argument] prefix.
1495 1664
1496 Possible values for the command are: 1665 Possible values for the command are:
1497 `emacs' The file will be visited by the current Emacs process. 1666 `emacs' The file will be visited by the current Emacs process.
1498 `default' Use the default application for this file type, which is the 1667 `default' Use the default application for this file type, which is the
1499 association for t in the list, most likely in the system-specific 1668 association for t in the list, most likely in the system-specific
1504 This command is specified by the entry whose car is `system'. 1673 This command is specified by the entry whose car is `system'.
1505 Most likely, the system-specific version of this variable 1674 Most likely, the system-specific version of this variable
1506 does define this command, but you can overrule/replace it 1675 does define this command, but you can overrule/replace it
1507 here. 1676 here.
1508 string A command to be executed by a shell; %s will be replaced 1677 string A command to be executed by a shell; %s will be replaced
1509 by the path to the file. If the file identifier is a regex, 1678 by the path to the file.
1510 %n will be replaced by the match of the nth match group.
1511 sexp A Lisp form which will be evaluated. The file path will 1679 sexp A Lisp form which will be evaluated. The file path will
1512 be available in the Lisp variable `file', the link itself 1680 be available in the Lisp variable `file'.
1513 in the Lisp variable `link'. If the file identifier is a regex,
1514 the original match data will be restored, so subexpression
1515 matches are accessible using (match-string n link).
1516 For more examples, see the system specific constants 1681 For more examples, see the system specific constants
1517 `org-file-apps-defaults-macosx' 1682 `org-file-apps-defaults-macosx'
1518 `org-file-apps-defaults-windowsnt' 1683 `org-file-apps-defaults-windowsnt'
1519 `org-file-apps-defaults-gnu'." 1684 `org-file-apps-defaults-gnu'."
1520 :group 'org-link-follow 1685 :group 'org-link-follow
1532 (const :tag "Use default" default) 1697 (const :tag "Use default" default)
1533 (const :tag "Use the system command" system) 1698 (const :tag "Use the system command" system)
1534 (string :tag "Command") 1699 (string :tag "Command")
1535 (sexp :tag "Lisp form"))))) 1700 (sexp :tag "Lisp form")))))
1536 1701
1702
1703
1537 (defgroup org-refile nil 1704 (defgroup org-refile nil
1538 "Options concerning refiling entries in Org-mode." 1705 "Options concerning refiling entries in Org-mode."
1539 :tag "Org Refile" 1706 :tag "Org Refile"
1540 :group 'org) 1707 :group 'org)
1541 1708
1555 :group 'org-remember 1722 :group 'org-remember
1556 :type 'directory) 1723 :type 'directory)
1557 1724
1558 (defcustom org-default-notes-file (convert-standard-filename "~/.notes") 1725 (defcustom org-default-notes-file (convert-standard-filename "~/.notes")
1559 "Default target for storing notes. 1726 "Default target for storing notes.
1560 Used by the hooks for remember.el. This can be a string, or nil to mean 1727 Used as a fall back file for org-remember.el and org-capture.el, for
1561 the value of `remember-data-file'. 1728 templates that do not specify a target file."
1562 You can set this on a per-template basis with the variable
1563 `org-remember-templates'."
1564 :group 'org-refile 1729 :group 'org-refile
1565 :group 'org-remember 1730 :group 'org-remember
1566 :type '(choice 1731 :type '(choice
1567 (const :tag "Default from remember-data-file" nil) 1732 (const :tag "Default from remember-data-file" nil)
1568 file)) 1733 file))
1580 :type '(choice 1745 :type '(choice
1581 (const :tag "Outline" outline) 1746 (const :tag "Outline" outline)
1582 (const :tag "Outline-path-completion" outline-path-completion))) 1747 (const :tag "Outline-path-completion" outline-path-completion)))
1583 1748
1584 (defcustom org-goto-max-level 5 1749 (defcustom org-goto-max-level 5
1585 "Maximum level to be considered when running org-goto with refile interface." 1750 "Maximum target level when running `org-goto' with refile interface."
1586 :group 'org-refile 1751 :group 'org-refile
1587 :type 'integer) 1752 :type 'integer)
1588 1753
1589 (defcustom org-reverse-note-order nil 1754 (defcustom org-reverse-note-order nil
1590 "Non-nil means store new notes at the beginning of a file or entry. 1755 "Non-nil means store new notes at the beginning of a file or entry.
1649 - a cons cell (:maxlevel . N). Any headline with level <= N is a target. 1814 - a cons cell (:maxlevel . N). Any headline with level <= N is a target.
1650 Note that, when `org-odd-levels-only' is set, level corresponds to 1815 Note that, when `org-odd-levels-only' is set, level corresponds to
1651 order in hierarchy, not to the number of stars. 1816 order in hierarchy, not to the number of stars.
1652 1817
1653 You can set the variable `org-refile-target-verify-function' to a function 1818 You can set the variable `org-refile-target-verify-function' to a function
1654 to verify each headline found by the simple critery above. 1819 to verify each headline found by the simple criteria above.
1655 1820
1656 When this variable is nil, all top-level headlines in the current buffer 1821 When this variable is nil, all top-level headlines in the current buffer
1657 are used, equivalent to the value `((nil . (:level . 1))'." 1822 are used, equivalent to the value `((nil . (:level . 1))'."
1658 :group 'org-refile 1823 :group 'org-refile
1659 :type '(repeat 1824 :type '(repeat
1681 subtree of the current entry should be excluded and move point to the end 1846 subtree of the current entry should be excluded and move point to the end
1682 of the subtree." 1847 of the subtree."
1683 :group 'org-refile 1848 :group 'org-refile
1684 :type 'function) 1849 :type 'function)
1685 1850
1851 (defcustom org-refile-use-cache nil
1852 "Non-nil means cache refile targets to speed up the process.
1853 The cache for a particular file will be updated automatically when
1854 the buffer has been killed, or when any of the marker used for flagging
1855 refile targets no longer points at a live buffer.
1856 If you have added new entries to a buffer that might themselves be targets,
1857 you need to clear the cache manually by pressing `C-0 C-c C-w' or, if you
1858 find that easier, `C-u C-u C-u C-c C-w'."
1859 :group 'org-refile
1860 :type 'boolean)
1861
1686 (defcustom org-refile-use-outline-path nil 1862 (defcustom org-refile-use-outline-path nil
1687 "Non-nil means provide refile targets as paths. 1863 "Non-nil means provide refile targets as paths.
1688 So a level 3 headline will be available as level1/level2/level3. 1864 So a level 3 headline will be available as level1/level2/level3.
1689 1865
1690 When the value is `file', also include the file name (without directory) 1866 When the value is `file', also include the file name (without directory)
1740 1916
1741 (defvar org-todo-interpretation-widgets 1917 (defvar org-todo-interpretation-widgets
1742 '( 1918 '(
1743 (:tag "Sequence (cycling hits every state)" sequence) 1919 (:tag "Sequence (cycling hits every state)" sequence)
1744 (:tag "Type (cycling directly to DONE)" type)) 1920 (:tag "Type (cycling directly to DONE)" type))
1745 "The available interpretation symbols for customizing 1921 "The available interpretation symbols for customizing `org-todo-keywords'.
1746 `org-todo-keywords'. 1922 Interested libraries should add to this list.")
1747 Interested libraries should add to this list.")
1748 1923
1749 (defcustom org-todo-keywords '((sequence "TODO" "DONE")) 1924 (defcustom org-todo-keywords '((sequence "TODO" "DONE"))
1750 "List of TODO entry keyword sequences and their interpretation. 1925 "List of TODO entry keyword sequences and their interpretation.
1751 \\<org-mode-map>This is a list of sequences. 1926 \\<org-mode-map>This is a list of sequences.
1752 1927
1768 1943
1769 Each keyword can optionally specify a character for fast state selection 1944 Each keyword can optionally specify a character for fast state selection
1770 \(in combination with the variable `org-use-fast-todo-selection') 1945 \(in combination with the variable `org-use-fast-todo-selection')
1771 and specifiers for state change logging, using the same syntax 1946 and specifiers for state change logging, using the same syntax
1772 that is used in the \"#+TODO:\" lines. For example, \"WAIT(w)\" says 1947 that is used in the \"#+TODO:\" lines. For example, \"WAIT(w)\" says
1773 that the WAIT state can be selected with the \"w\" key. \"WAIT(w!)\" 1948 that the WAIT state can be selected with the \"w\" key. \"WAIT(w!)\"
1774 indicates to record a time stamp each time this state is selected. 1949 indicates to record a time stamp each time this state is selected.
1775 1950
1776 Each keyword may also specify if a timestamp or a note should be 1951 Each keyword may also specify if a timestamp or a note should be
1777 recorded when entering or leaving the state, by adding additional 1952 recorded when entering or leaving the state, by adding additional
1778 characters in the parenthesis after the keyword. This looks like this: 1953 characters in the parenthesis after the keyword. This looks like this:
2112 "Headings for notes added to entries. 2287 "Headings for notes added to entries.
2113 The value is an alist, with the car being a symbol indicating the note 2288 The value is an alist, with the car being a symbol indicating the note
2114 context, and the cdr is the heading to be used. The heading may also be the 2289 context, and the cdr is the heading to be used. The heading may also be the
2115 empty string. 2290 empty string.
2116 %t in the heading will be replaced by a time stamp. 2291 %t in the heading will be replaced by a time stamp.
2292 %T will be an active time stamp instead the default inactive one
2117 %s will be replaced by the new TODO state, in double quotes. 2293 %s will be replaced by the new TODO state, in double quotes.
2118 %S will be replaced by the old TODO state, in double quotes. 2294 %S will be replaced by the old TODO state, in double quotes.
2119 %u will be replaced by the user name. 2295 %u will be replaced by the user name.
2120 %U will be replaced by the full user name. 2296 %U will be replaced by the full user name.
2121 2297
2193 When nil, the state change notes will be ordered according to time." 2369 When nil, the state change notes will be ordered according to time."
2194 :group 'org-todo 2370 :group 'org-todo
2195 :group 'org-progress 2371 :group 'org-progress
2196 :type 'boolean) 2372 :type 'boolean)
2197 2373
2374 (defcustom org-todo-repeat-to-state nil
2375 "The TODO state to which a repeater should return the repeating task.
2376 By default this is the first task in a TODO sequence, or the previous state
2377 in a TODO_TYP set. But you can specify another task here.
2378 alternatively, set the :REPEAT_TO_STATE: property of the entry."
2379 :group 'org-todo
2380 :type '(choice (const :tag "Head of sequence" nil)
2381 (string :tag "Specific state")))
2382
2198 (defcustom org-log-repeat 'time 2383 (defcustom org-log-repeat 'time
2199 "Non-nil means record moving through the DONE state when triggering repeat. 2384 "Non-nil means record moving through the DONE state when triggering repeat.
2200 An auto-repeating task is immediately switched back to TODO when 2385 An auto-repeating task is immediately switched back to TODO when
2201 marked DONE. If you are not logging state changes (by adding \"@\" 2386 marked DONE. If you are not logging state changes (by adding \"@\"
2202 or \"!\" to the TODO keyword definition), or set `org-log-done' to 2387 or \"!\" to the TODO keyword definition), or set `org-log-done' to
2203 record a closing note, there will be no record of the task moving 2388 record a closing note, there will be no record of the task moving
2204 through DONE. This variable forces taking a note anyway. 2389 through DONE. This variable forces taking a note anyway.
2205 2390
2206 nil Don't force a record 2391 nil Don't force a record
2285 of N minutes, as given by the second value. 2470 of N minutes, as given by the second value.
2286 2471
2287 When a setting is 0 or 1, insert the time unmodified. Useful rounding 2472 When a setting is 0 or 1, insert the time unmodified. Useful rounding
2288 numbers should be factors of 60, so for example 5, 10, 15. 2473 numbers should be factors of 60, so for example 5, 10, 15.
2289 2474
2290 When this is larger than 1, you can still force an exact time-stamp by using 2475 When this is larger than 1, you can still force an exact time stamp by using
2291 a double prefix argument to a time-stamp command like `C-c .' or `C-c !', 2476 a double prefix argument to a time stamp command like `C-c .' or `C-c !',
2292 and by using a prefix arg to `S-up/down' to specify the exact number 2477 and by using a prefix arg to `S-up/down' to specify the exact number
2293 of minutes to shift." 2478 of minutes to shift."
2294 :group 'org-time 2479 :group 'org-time
2295 :get '(lambda (var) ; Make sure all entries have 5 elements 2480 :get '(lambda (var) ; Make sure both elements are there
2296 (if (integerp (default-value var)) 2481 (if (integerp (default-value var))
2297 (list (default-value var) 5) 2482 (list (default-value var) 5)
2298 (default-value var))) 2483 (default-value var)))
2299 :type '(list 2484 :type '(list
2300 (integer :tag "when inserting times") 2485 (integer :tag "when inserting times")
2333 (if inactive 2518 (if inactive
2334 (concat "[" (substring f 1 -1) "]") 2519 (concat "[" (substring f 1 -1) "]")
2335 f))) 2520 f)))
2336 2521
2337 (defcustom org-time-clocksum-format "%d:%02d" 2522 (defcustom org-time-clocksum-format "%d:%02d"
2338 "The format string used when creating CLOCKSUM lines, or when 2523 "The format string used when creating CLOCKSUM lines.
2339 org-mode generates a time duration." 2524 This is also used when org-mode generates a time duration."
2340 :group 'org-time 2525 :group 'org-time
2341 :type 'string) 2526 :type 'string)
2342 2527
2343 (defcustom org-time-clocksum-use-fractional nil 2528 (defcustom org-time-clocksum-use-fractional nil
2344 "If non-nil, \\[org-clock-display] uses fractional times. 2529 "If non-nil, \\[org-clock-display] uses fractional times.
2365 2550
2366 (defcustom org-read-date-prefer-future t 2551 (defcustom org-read-date-prefer-future t
2367 "Non-nil means assume future for incomplete date input from user. 2552 "Non-nil means assume future for incomplete date input from user.
2368 This affects the following situations: 2553 This affects the following situations:
2369 1. The user gives a month but not a year. 2554 1. The user gives a month but not a year.
2370 For example, if it is april and you enter \"feb 2\", this will be read 2555 For example, if it is April and you enter \"feb 2\", this will be read
2371 as feb 2, *next* year. \"May 5\", however, will be this year. 2556 as Feb 2, *next* year. \"May 5\", however, will be this year.
2372 2. The user gives a day, but no month. 2557 2. The user gives a day, but no month.
2373 For example, if today is the 15th, and you enter \"3\", Org-mode will 2558 For example, if today is the 15th, and you enter \"3\", Org-mode will
2374 read this as the third of *next* month. However, if you enter \"17\", 2559 read this as the third of *next* month. However, if you enter \"17\",
2375 it will be considered as *this* month. 2560 it will be considered as *this* month.
2376 2561
2616 (const :tag "No, don't list them" nil) 2801 (const :tag "No, don't list them" nil)
2617 (const :tag "Yes, do list them" t) 2802 (const :tag "Yes, do list them" t)
2618 (const :tag "List them, indented with leading dots" indented))) 2803 (const :tag "List them, indented with leading dots" indented)))
2619 2804
2620 (defcustom org-tags-sort-function nil 2805 (defcustom org-tags-sort-function nil
2621 "When set, tags are sorted using this function as a comparator" 2806 "When set, tags are sorted using this function as a comparator."
2622 :group 'org-tags 2807 :group 'org-tags
2623 :type '(choice 2808 :type '(choice
2624 (const :tag "No sorting" nil) 2809 (const :tag "No sorting" nil)
2625 (const :tag "Alphabetical" string<) 2810 (const :tag "Alphabetical" string<)
2626 (const :tag "Reverse alphabetical" string>) 2811 (const :tag "Reverse alphabetical" string>)
2647 :type 'string) 2832 :type 'string)
2648 2833
2649 (defcustom org-use-property-inheritance nil 2834 (defcustom org-use-property-inheritance nil
2650 "Non-nil means properties apply also for sublevels. 2835 "Non-nil means properties apply also for sublevels.
2651 2836
2652 This setting is chiefly used during property searches. Turning it on can 2837 This setting is chiefly used during property searches. Turning it on can
2653 cause significant overhead when doing a search, which is why it is not 2838 cause significant overhead when doing a search, which is why it is not
2654 on by default. 2839 on by default.
2655 2840
2656 When nil, only the properties directly given in the current entry count. 2841 When nil, only the properties directly given in the current entry count.
2657 When t, every property is inherited. The value may also be a list of 2842 When t, every property is inherited. The value may also be a list of
2946 :group 'org-latex 3131 :group 'org-latex
2947 :type 'string) 3132 :type 'string)
2948 3133
2949 (defvar org-format-latex-header-extra nil) 3134 (defvar org-format-latex-header-extra nil)
2950 3135
3136 (defun org-set-packages-alist (var val)
3137 "Set the packages alist and make sure it has 3 elements per entry."
3138 (set var (mapcar (lambda (x)
3139 (if (and (consp x) (= (length x) 2))
3140 (list (car x) (nth 1 x) t)
3141 x))
3142 val)))
3143
3144 (defun org-get-packages-alist (var)
3145
3146 "Get the packages alist and make sure it has 3 elements per entry."
3147 (mapcar (lambda (x)
3148 (if (and (consp x) (= (length x) 2))
3149 (list (car x) (nth 1 x) t)
3150 x))
3151 (default-value var)))
3152
2951 ;; The following variables are defined here because is it also used 3153 ;; The following variables are defined here because is it also used
2952 ;; when formatting latex fragments. Originally it was part of the 3154 ;; when formatting latex fragments. Originally it was part of the
2953 ;; LaTeX exporter, which is why the name includes "export". 3155 ;; LaTeX exporter, which is why the name includes "export".
2954 (defcustom org-export-latex-default-packages-alist 3156 (defcustom org-export-latex-default-packages-alist
2955 '(("AUTO" "inputenc") 3157 '(("AUTO" "inputenc" t)
2956 ("T1" "fontenc") 3158 ("T1" "fontenc" t)
2957 ("" "fixltx2e") 3159 ("" "fixltx2e" nil)
2958 ("" "graphicx") 3160 ("" "graphicx" t)
2959 ("" "longtable") 3161 ("" "longtable" nil)
2960 ("" "float") 3162 ("" "float" nil)
2961 ("" "wrapfig") 3163 ("" "wrapfig" nil)
2962 ("" "soul") 3164 ("" "soul" t)
2963 ("" "t1enc") 3165 ("" "t1enc" t)
2964 ("" "textcomp") 3166 ("" "textcomp" t)
2965 ("" "marvosym") 3167 ("" "marvosym" t)
2966 ("" "wasysym") 3168 ("" "wasysym" t)
2967 ("" "latexsym") 3169 ("" "latexsym" t)
2968 ("" "amssymb") 3170 ("" "amssymb" t)
2969 ("" "hyperref") 3171 ("" "hyperref" nil)
2970 "\\tolerance=1000" 3172 "\\tolerance=1000"
2971 ) 3173 )
2972 "Alist of default packages to be inserted in the header. 3174 "Alist of default packages to be inserted in the header.
2973 Change this only if one of the packages here causes an incompatibility 3175 Change this only if one of the packages here causes an incompatibility
2974 with another package you are using. 3176 with another package you are using.
2975 The packages in this list are needed by one part or another of Org-mode 3177 The packages in this list are needed by one part or another of Org-mode
2976 to function properly. 3178 to function properly.
2977 3179
2978 - inputenc, fontenc, t1enc: for basic font and character selection 3180 - inputenc, fontenc, t1enc: for basic font and character selection
2979 - textcomp, marvosymb, wasysym, latexsym, amssym: for various symbols used 3181 - textcomp, marvosymb, wasysym, latexsym, amssym: for various symbols used
2980 for interpreting the entities in `org-entities'. You can skip some of these 3182 for interpreting the entities in `org-entities'. You can skip some of these
2981 packages if you don't use any of the symbols in it. 3183 packages if you don't use any of the symbols in it.
2985 - hyperref: for cross references 3187 - hyperref: for cross references
2986 3188
2987 Therefore you should not modify this variable unless you know what you 3189 Therefore you should not modify this variable unless you know what you
2988 are doing. The one reason to change it anyway is that you might be loading 3190 are doing. The one reason to change it anyway is that you might be loading
2989 some other package that conflicts with one of the default packages. 3191 some other package that conflicts with one of the default packages.
2990 Each cell is of the format \( \"options\" \"package\" \)." 3192 Each cell is of the format \( \"options\" \"package\" snippet-flag\).
3193 If SNIPPET-FLAG is t, the package also needs to be included when
3194 compiling LaTeX snippets into images for inclusion into HTML."
2991 :group 'org-export-latex 3195 :group 'org-export-latex
3196 :set 'org-set-packages-alist
3197 :get 'org-get-packages-alist
2992 :type '(repeat 3198 :type '(repeat
2993 (choice 3199 (choice
2994 (string :tag "A line of LaTeX")
2995 (list :tag "options/package pair" 3200 (list :tag "options/package pair"
2996 (string :tag "options") 3201 (string :tag "options")
2997 (string :tag "package"))))) 3202 (string :tag "package")
3203 (boolean :tag "Snippet"))
3204 (string :tag "A line of LaTeX"))))
2998 3205
2999 (defcustom org-export-latex-packages-alist nil 3206 (defcustom org-export-latex-packages-alist nil
3000 "Alist of packages to be inserted in every LaTeX the header. 3207 "Alist of packages to be inserted in every LaTeX header.
3001 These will be inserted after `org-export-latex-default-packages-alist'. 3208 These will be inserted after `org-export-latex-default-packages-alist'.
3002 Each cell is of the format \( \"options\" \"package\" \). 3209 Each cell is of the format \( \"options\" \"package\" snippet-flag \).
3003 Make sure that you only lis packages here which: 3210 SNIPPET-FLAG, when t, indicates that this package is also needed when
3211 turning LaTeX snippets into images for inclusion into HTML.
3212 Make sure that you only list packages here which:
3004 - you want in every file 3213 - you want in every file
3005 - do not conflict with the default packages in 3214 - do not conflict with the default packages in
3006 `org-export-latex-default-packages-alist' 3215 `org-export-latex-default-packages-alist'
3007 - do not conflict with the setup in `org-format-latex-header'." 3216 - do not conflict with the setup in `org-format-latex-header'."
3008 :group 'org-export-latex 3217 :group 'org-export-latex
3218 :set 'org-set-packages-alist
3219 :get 'org-get-packages-alist
3009 :type '(repeat 3220 :type '(repeat
3010 (choice 3221 (choice
3011 (string :tag "A line of LaTeX")
3012 (list :tag "options/package pair" 3222 (list :tag "options/package pair"
3013 (string :tag "options") 3223 (string :tag "options")
3014 (string :tag "package"))))) 3224 (string :tag "package")
3225 (boolean :tag "Snippet"))
3226 (string :tag "A line of LaTeX"))))
3227
3015 3228
3016 (defgroup org-appearance nil 3229 (defgroup org-appearance nil
3017 "Settings for Org-mode appearance." 3230 "Settings for Org-mode appearance."
3018 :tag "Org Appearance" 3231 :tag "Org Appearance"
3019 :group 'org) 3232 :group 'org)
3082 (defcustom org-hide-emphasis-markers nil 3295 (defcustom org-hide-emphasis-markers nil
3083 "Non-nil mean font-lock should hide the emphasis marker characters." 3296 "Non-nil mean font-lock should hide the emphasis marker characters."
3084 :group 'org-appearance 3297 :group 'org-appearance
3085 :type 'boolean) 3298 :type 'boolean)
3086 3299
3300 (defcustom org-pretty-entities nil
3301 "Non-nil means show entities as UTF8 characters.
3302 When nil, the \\name form remains in the buffer."
3303 :group 'org-appearance
3304 :type 'boolean)
3305
3306 (defcustom org-pretty-entities-include-sub-superscripts t
3307 "Non-nil means, pretty entity display includes formatting sub/superscripts."
3308 :group 'org-appearance
3309 :type 'boolean)
3310
3087 (defvar org-emph-re nil 3311 (defvar org-emph-re nil
3088 "Regular expression for matching emphasis.") 3312 "Regular expression for matching emphasis.
3313 After a match, the match groups contain these elements:
3314 1 The character before the proper match, or empty at beginning of line
3315 2 The proper match, including the leading and trailing markers
3316 3 The leading marker like * or /, indicating the type of highlighting
3317 4 The text between the emphasis markers, not including the markers
3318 5 The character after the match, empty at the end of a line")
3089 (defvar org-verbatim-re nil 3319 (defvar org-verbatim-re nil
3090 "Regular expression for matching verbatim text.") 3320 "Regular expression for matching verbatim text.")
3091 (defvar org-emphasis-regexp-components) ; defined just below 3321 (defvar org-emphasis-regexp-components) ; defined just below
3092 (defvar org-emphasis-alist) ; defined just below 3322 (defvar org-emphasis-alist) ; defined just below
3093 (defun org-set-emph-re (var val) 3323 (defun org-set-emph-re (var val)
3185 Text starting and ending with a special character will be emphasized, for 3415 Text starting and ending with a special character will be emphasized, for
3186 example *bold*, _underlined_ and /italic/. This variable sets the marker 3416 example *bold*, _underlined_ and /italic/. This variable sets the marker
3187 characters, the face to be used by font-lock for highlighting in Org-mode 3417 characters, the face to be used by font-lock for highlighting in Org-mode
3188 Emacs buffers, and the HTML tags to be used for this. 3418 Emacs buffers, and the HTML tags to be used for this.
3189 For LaTeX export, see the variable `org-export-latex-emphasis-alist'. 3419 For LaTeX export, see the variable `org-export-latex-emphasis-alist'.
3420 For DocBook export, see the variable `org-export-docbook-emphasis-alist'.
3190 Use customize to modify this, or restart Emacs after changing it." 3421 Use customize to modify this, or restart Emacs after changing it."
3191 :group 'org-appearance 3422 :group 'org-appearance
3192 :set 'org-set-emph-re 3423 :set 'org-set-emph-re
3193 :type '(repeat 3424 :type '(repeat
3194 (list 3425 (list
3280 "org-agenda" (&optional end)) 3511 "org-agenda" (&optional end))
3281 (declare-function org-inlinetask-remove-END-maybe "org-inlinetask" ()) 3512 (declare-function org-inlinetask-remove-END-maybe "org-inlinetask" ())
3282 (declare-function org-indent-mode "org-indent" (&optional arg)) 3513 (declare-function org-indent-mode "org-indent" (&optional arg))
3283 (declare-function parse-time-string "parse-time" (string)) 3514 (declare-function parse-time-string "parse-time" (string))
3284 (declare-function org-attach-reveal "org-attach" (&optional if-exists)) 3515 (declare-function org-attach-reveal "org-attach" (&optional if-exists))
3516 (declare-function org-export-latex-fix-inputenc "org-latex" ())
3285 (defvar remember-data-file) 3517 (defvar remember-data-file)
3286 (defvar texmathp-why) 3518 (defvar texmathp-why)
3287 (declare-function speedbar-line-directory "speedbar" (&optional depth)) 3519 (declare-function speedbar-line-directory "speedbar" (&optional depth))
3288 (declare-function table--at-cell-p "table" (position &optional object at-column)) 3520 (declare-function table--at-cell-p "table" (position &optional object at-column))
3289 3521
3296 3528
3297 ;; Some table stuff that needs to be defined here, because it is used 3529 ;; Some table stuff that needs to be defined here, because it is used
3298 ;; by the functions setting up org-mode or checking for table context. 3530 ;; by the functions setting up org-mode or checking for table context.
3299 3531
3300 (defconst org-table-any-line-regexp "^[ \t]*\\(|\\|\\+-[-+]\\)" 3532 (defconst org-table-any-line-regexp "^[ \t]*\\(|\\|\\+-[-+]\\)"
3301 "Detects an org-type or table-type table.") 3533 "Detect an org-type or table-type table.")
3302 (defconst org-table-line-regexp "^[ \t]*|" 3534 (defconst org-table-line-regexp "^[ \t]*|"
3303 "Detects an org-type table line.") 3535 "Detect an org-type table line.")
3304 (defconst org-table-dataline-regexp "^[ \t]*|[^-]" 3536 (defconst org-table-dataline-regexp "^[ \t]*|[^-]"
3305 "Detects an org-type table line.") 3537 "Detect an org-type table line.")
3306 (defconst org-table-hline-regexp "^[ \t]*|-" 3538 (defconst org-table-hline-regexp "^[ \t]*|-"
3307 "Detects an org-type table hline.") 3539 "Detect an org-type table hline.")
3308 (defconst org-table1-hline-regexp "^[ \t]*\\+-[-+]" 3540 (defconst org-table1-hline-regexp "^[ \t]*\\+-[-+]"
3309 "Detects a table-type table hline.") 3541 "Detect a table-type table hline.")
3310 (defconst org-table-any-border-regexp "^[ \t]*[^|+ \t]" 3542 (defconst org-table-any-border-regexp "^[ \t]*[^|+ \t]"
3311 "Searching from within a table (any type) this finds the first line 3543 "Detect the first line outside a table when searching from within it.
3312 outside the table.") 3544 This works for both table types.")
3313 3545
3314 ;; Autoload the functions in org-table.el that are needed by functions here. 3546 ;; Autoload the functions in org-table.el that are needed by functions here.
3315 3547
3316 (eval-and-compile 3548 (eval-and-compile
3317 (org-autoload "org-table" 3549 (org-autoload "org-table"
3334 org-table-next-field org-table-next-row org-table-paste-rectangle 3566 org-table-next-field org-table-next-row org-table-paste-rectangle
3335 org-table-previous-field org-table-recalculate 3567 org-table-previous-field org-table-recalculate
3336 org-table-rotate-recalc-marks org-table-sort-lines org-table-sum 3568 org-table-rotate-recalc-marks org-table-sort-lines org-table-sum
3337 org-table-toggle-coordinate-overlays 3569 org-table-toggle-coordinate-overlays
3338 org-table-toggle-formula-debugger org-table-wrap-region 3570 org-table-toggle-formula-debugger org-table-wrap-region
3339 orgtbl-mode turn-on-orgtbl org-table-to-lisp))) 3571 orgtbl-mode turn-on-orgtbl org-table-to-lisp
3572 orgtbl-to-generic orgtbl-to-tsv orgtbl-to-csv orgtbl-to-latex
3573 orgtbl-to-orgtbl orgtbl-to-html orgtbl-to-texinfo)))
3340 3574
3341 (defun org-at-table-p (&optional table-type) 3575 (defun org-at-table-p (&optional table-type)
3342 "Return t if the cursor is inside an org-type table. 3576 "Return t if the cursor is inside an org-type table.
3343 If TABLE-TYPE is non-nil, also check for table.el-type tables." 3577 If TABLE-TYPE is non-nil, also check for table.el-type tables."
3344 (if org-enable-table-editor 3578 (if org-enable-table-editor
3374 (if (table--at-cell-p (point)) 3608 (if (table--at-cell-p (point))
3375 t 3609 t
3376 (message "recognizing table.el table...") 3610 (message "recognizing table.el table...")
3377 (table-recognize-table) 3611 (table-recognize-table)
3378 (message "recognizing table.el table...done"))) 3612 (message "recognizing table.el table...done")))
3379 (error "This should not happen...")) 3613 (error "This should not happen"))
3380 t) 3614 t)
3381 nil) 3615 nil)
3382 nil)) 3616 nil))
3383 3617
3384 (defun org-at-table-hline-p () 3618 (defun org-at-table-hline-p ()
3389 (looking-at org-table-hline-regexp)) 3623 (looking-at org-table-hline-regexp))
3390 nil)) 3624 nil))
3391 3625
3392 (defvar org-table-clean-did-remove-column nil) 3626 (defvar org-table-clean-did-remove-column nil)
3393 3627
3394 (defun org-table-map-tables (function) 3628 (defun org-table-map-tables (function &optional quietly)
3395 "Apply FUNCTION to the start of all tables in the buffer." 3629 "Apply FUNCTION to the start of all tables in the buffer."
3396 (save-excursion 3630 (save-excursion
3397 (save-restriction 3631 (save-restriction
3398 (widen) 3632 (widen)
3399 (goto-char (point-min)) 3633 (goto-char (point-min))
3400 (while (re-search-forward org-table-any-line-regexp nil t) 3634 (while (re-search-forward org-table-any-line-regexp nil t)
3401 (message "Mapping tables: %d%%" (/ (* 100.0 (point)) (buffer-size))) 3635 (unless quietly
3636 (message "Mapping tables: %d%%" (/ (* 100.0 (point)) (buffer-size))))
3402 (beginning-of-line 1) 3637 (beginning-of-line 1)
3403 (when (looking-at org-table-line-regexp) 3638 (when (looking-at org-table-line-regexp)
3404 (save-excursion (funcall function)) 3639 (save-excursion (funcall function))
3405 (or (looking-at org-table-line-regexp) 3640 (or (looking-at org-table-line-regexp)
3406 (forward-char 1))) 3641 (forward-char 1)))
3407 (re-search-forward org-table-any-border-regexp nil 1)))) 3642 (re-search-forward org-table-any-border-regexp nil 1))))
3408 (message "Mapping tables: done")) 3643 (unless quietly (message "Mapping tables: done")))
3409 3644
3410 ;; Declare and autoload functions from org-exp.el & Co 3645 ;; Declare and autoload functions from org-exp.el & Co
3411 3646
3412 (declare-function org-default-export-plist "org-exp") 3647 (declare-function org-default-export-plist "org-exp")
3413 (declare-function org-infile-export-plist "org-exp") 3648 (declare-function org-infile-export-plist "org-exp")
3456 3691
3457 (eval-and-compile 3692 (eval-and-compile
3458 (org-autoload "org-remember" 3693 (org-autoload "org-remember"
3459 '(org-remember-insinuate org-remember-annotation 3694 '(org-remember-insinuate org-remember-annotation
3460 org-remember-apply-template org-remember org-remember-handler))) 3695 org-remember-apply-template org-remember org-remember-handler)))
3696
3697 (eval-and-compile
3698 (org-autoload "org-capture"
3699 '(org-capture org-capture-insert-template-here
3700 org-capture-import-remember-templates)))
3461 3701
3462 ;; Autoload org-clock.el 3702 ;; Autoload org-clock.el
3463 3703
3464 3704
3465 (declare-function org-clock-save-markers-for-cut-and-paste "org-clock" 3705 (declare-function org-clock-save-markers-for-cut-and-paste "org-clock"
3823 (make-variable-buffer-local 'org-keyword-time-regexp) 4063 (make-variable-buffer-local 'org-keyword-time-regexp)
3824 (defvar org-keyword-time-not-clock-regexp nil 4064 (defvar org-keyword-time-not-clock-regexp nil
3825 "Matches any of the 3 keywords, together with the time stamp.") 4065 "Matches any of the 3 keywords, together with the time stamp.")
3826 (make-variable-buffer-local 'org-keyword-time-not-clock-regexp) 4066 (make-variable-buffer-local 'org-keyword-time-not-clock-regexp)
3827 (defvar org-maybe-keyword-time-regexp nil 4067 (defvar org-maybe-keyword-time-regexp nil
3828 "Matches a timestamp, possibly preceeded by a keyword.") 4068 "Matches a timestamp, possibly preceded by a keyword.")
3829 (make-variable-buffer-local 'org-maybe-keyword-time-regexp) 4069 (make-variable-buffer-local 'org-maybe-keyword-time-regexp)
3830 (defvar org-planning-or-clock-line-re nil 4070 (defvar org-planning-or-clock-line-re nil
3831 "Matches a line with planning or clock info.") 4071 "Matches a line with planning or clock info.")
3832 (make-variable-buffer-local 'org-planning-or-clock-line-re) 4072 (make-variable-buffer-local 'org-planning-or-clock-line-re)
3833 (defvar org-all-time-keywords nil 4073 (defvar org-all-time-keywords nil
3919 ("constcgs" constants-unit-system cgs) 4159 ("constcgs" constants-unit-system cgs)
3920 ("constSI" constants-unit-system SI) 4160 ("constSI" constants-unit-system SI)
3921 ("noptag" org-tag-persistent-alist nil) 4161 ("noptag" org-tag-persistent-alist nil)
3922 ("hideblocks" org-hide-block-startup t) 4162 ("hideblocks" org-hide-block-startup t)
3923 ("nohideblocks" org-hide-block-startup nil) 4163 ("nohideblocks" org-hide-block-startup nil)
3924 ("beamer" org-startup-with-beamer-mode t)) 4164 ("beamer" org-startup-with-beamer-mode t)
4165 ("entitiespretty" org-pretty-entities t)
4166 ("entitiesplain" org-pretty-entities nil))
3925 "Variable associated with STARTUP options for org-mode. 4167 "Variable associated with STARTUP options for org-mode.
3926 Each element is a list of three items: The startup options as written 4168 Each element is a list of three items: The startup options as written
3927 in the #+STARTUP line, the corresponding variable, and the value to 4169 in the #+STARTUP line, the corresponding variable, and the value to
3928 set this variable to if the option is found. An optional forth element PUSH 4170 set this variable to if the option is found. An optional forth element PUSH
3929 means to push this value onto the list in the variable.") 4171 means to push this value onto the list in the variable.")
3942 (org-set-local 'org-file-properties nil) 4184 (org-set-local 'org-file-properties nil)
3943 (org-set-local 'org-file-tags nil) 4185 (org-set-local 'org-file-tags nil)
3944 (let ((re (org-make-options-regexp 4186 (let ((re (org-make-options-regexp
3945 '("CATEGORY" "TODO" "COLUMNS" 4187 '("CATEGORY" "TODO" "COLUMNS"
3946 "STARTUP" "ARCHIVE" "FILETAGS" "TAGS" "LINK" "PRIORITIES" 4188 "STARTUP" "ARCHIVE" "FILETAGS" "TAGS" "LINK" "PRIORITIES"
3947 "CONSTANTS" "PROPERTY" "DRAWERS" "SETUPFILE" "LATEX_CLASS") 4189 "CONSTANTS" "PROPERTY" "DRAWERS" "SETUPFILE" "LATEX_CLASS"
4190 "OPTIONS")
3948 "\\(?:[a-zA-Z][0-9a-zA-Z_]*_TODO\\)")) 4191 "\\(?:[a-zA-Z][0-9a-zA-Z_]*_TODO\\)"))
3949 (splitre "[ \t]+") 4192 (splitre "[ \t]+")
4193 (scripts org-use-sub-superscripts)
3950 kwds kws0 kwsa key log value cat arch tags const links hw dws 4194 kwds kws0 kwsa key log value cat arch tags const links hw dws
3951 tail sep kws1 prio props ftags drawers beamer-p 4195 tail sep kws1 prio props ftags drawers beamer-p
3952 ext-setup-or-nil setup-contents (start 0)) 4196 ext-setup-or-nil setup-contents (start 0))
3953 (save-excursion 4197 (save-excursion
3954 (save-restriction 4198 (save-restriction
3959 (setq start (match-end 0))) 4203 (setq start (match-end 0)))
3960 (and (setq ext-setup-or-nil nil start 0) 4204 (and (setq ext-setup-or-nil nil start 0)
3961 (re-search-forward re nil t))) 4205 (re-search-forward re nil t)))
3962 (setq key (upcase (match-string 1 ext-setup-or-nil)) 4206 (setq key (upcase (match-string 1 ext-setup-or-nil))
3963 value (org-match-string-no-properties 2 ext-setup-or-nil)) 4207 value (org-match-string-no-properties 2 ext-setup-or-nil))
4208 (if (stringp value) (setq value (org-trim value)))
3964 (cond 4209 (cond
3965 ((equal key "CATEGORY") 4210 ((equal key "CATEGORY")
3966 (if (string-match "[ \t]+$" value)
3967 (setq value (replace-match "" t t value)))
3968 (setq cat value)) 4211 (setq cat value))
3969 ((member key '("SEQ_TODO" "TODO")) 4212 ((member key '("SEQ_TODO" "TODO"))
3970 (push (cons 'sequence (org-split-string value splitre)) kwds)) 4213 (push (cons 'sequence (org-split-string value splitre)) kwds))
3971 ((equal key "TYP_TODO") 4214 ((equal key "TYP_TODO")
3972 (push (cons 'type (org-split-string value splitre)) kwds)) 4215 (push (cons 'type (org-split-string value splitre)) kwds))
4013 (if (not (listp (symbol-value var))) 4256 (if (not (listp (symbol-value var)))
4014 (set (make-local-variable var) nil)) 4257 (set (make-local-variable var) nil))
4015 (set (make-local-variable var) (symbol-value var)) 4258 (set (make-local-variable var) (symbol-value var))
4016 (add-to-list var val)))))) 4259 (add-to-list var val))))))
4017 ((equal key "ARCHIVE") 4260 ((equal key "ARCHIVE")
4018 (string-match " *$" value) 4261 (setq arch value)
4019 (setq arch (replace-match "" t t value))
4020 (remove-text-properties 0 (length arch) 4262 (remove-text-properties 0 (length arch)
4021 '(face t fontified t) arch)) 4263 '(face t fontified t) arch))
4022 ((equal key "LATEX_CLASS") 4264 ((equal key "LATEX_CLASS")
4023 (setq beamer-p (equal value "beamer"))) 4265 (setq beamer-p (equal value "beamer")))
4266 ((equal key "OPTIONS")
4267 (if (string-match "\\([ \t]\\|\\`\\)\\^:\\(t\\|nil\\|{}\\)" value)
4268 (setq scripts (read (match-string 2 value)))))
4024 ((equal key "SETUPFILE") 4269 ((equal key "SETUPFILE")
4025 (setq setup-contents (org-file-contents 4270 (setq setup-contents (org-file-contents
4026 (expand-file-name 4271 (expand-file-name
4027 (org-remove-double-quotes value)) 4272 (org-remove-double-quotes value))
4028 'noerror)) 4273 'noerror))
4031 (setq ext-setup-or-nil 4276 (setq ext-setup-or-nil
4032 (concat (substring ext-setup-or-nil 0 start) 4277 (concat (substring ext-setup-or-nil 0 start)
4033 "\n" setup-contents "\n" 4278 "\n" setup-contents "\n"
4034 (substring ext-setup-or-nil start))))) 4279 (substring ext-setup-or-nil start)))))
4035 )))) 4280 ))))
4281 (org-set-local 'org-use-sub-superscripts scripts)
4036 (when cat 4282 (when cat
4037 (org-set-local 'org-category (intern cat)) 4283 (org-set-local 'org-category (intern cat))
4038 (push (cons "CATEGORY" cat) props)) 4284 (push (cons "CATEGORY" cat) props))
4039 (when prio 4285 (when prio
4040 (if (< (length prio) 3) (setq prio '("A" "C" "B"))) 4286 (if (< (length prio) 3) (setq prio '("A" "C" "B")))
4157 "\\)\\>\\)?\\(?:[ \t]*\\(\\[#.\\]\\)\\)?[ \t]*\\(.*?\\)" 4403 "\\)\\>\\)?\\(?:[ \t]*\\(\\[#.\\]\\)\\)?[ \t]*\\(.*?\\)"
4158 "\\(?:[ \t]+\\(:[[:alnum:]_@:]+:\\)\\)?[ \t]*$") 4404 "\\(?:[ \t]+\\(:[[:alnum:]_@:]+:\\)\\)?[ \t]*$")
4159 org-complex-heading-regexp-format 4405 org-complex-heading-regexp-format
4160 (concat "^\\(\\*+\\)[ \t]+\\(?:\\(" 4406 (concat "^\\(\\*+\\)[ \t]+\\(?:\\("
4161 (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") 4407 (mapconcat 'regexp-quote org-todo-keywords-1 "\\|")
4162 "\\)\\>\\)?\\(?:[ \t]*\\(\\[#.\\]\\)\\)?[ \t]*\\(%s\\)" 4408 "\\)\\>\\)?"
4409 "\\(?:[ \t]*\\(\\[#.\\]\\)\\)?"
4410 "\\(?:[ \t]*\\(?:\\[[0-9%%/]+\\]\\)\\)?" ;; stats cookie
4411 "[ \t]*\\(%s\\)"
4412 "\\(?:[ \t]*\\(?:\\[[0-9%%/]+\\]\\)\\)?" ;; stats cookie
4163 "\\(?:[ \t]+\\(:[[:alnum:]_@:]+:\\)\\)?[ \t]*$") 4413 "\\(?:[ \t]+\\(:[[:alnum:]_@:]+:\\)\\)?[ \t]*$")
4164 org-nl-done-regexp 4414 org-nl-done-regexp
4165 (concat "\n\\*+[ \t]+" 4415 (concat "\n\\*+[ \t]+"
4166 "\\(?:" (mapconcat 'regexp-quote org-done-keywords "\\|") 4416 "\\(?:" (mapconcat 'regexp-quote org-done-keywords "\\|")
4167 "\\)" "\\>") 4417 "\\)" "\\>")
4220 "Return the contents of FILE, as a string." 4470 "Return the contents of FILE, as a string."
4221 (if (or (not file) 4471 (if (or (not file)
4222 (not (file-readable-p file))) 4472 (not (file-readable-p file)))
4223 (if noerror 4473 (if noerror
4224 (progn 4474 (progn
4225 (message "Cannot read file %s" file) 4475 (message "Cannot read file \"%s\"" file)
4226 (ding) (sit-for 2) 4476 (ding) (sit-for 2)
4227 "") 4477 "")
4228 (error "Cannot read file %s" file)) 4478 (error "Cannot read file \"%s\"" file))
4229 (with-temp-buffer 4479 (with-temp-buffer
4230 (insert-file-contents file) 4480 (insert-file-contents file)
4231 (buffer-string)))) 4481 (buffer-string))))
4232 4482
4233 (defun org-extract-log-state-settings (x) 4483 (defun org-extract-log-state-settings (x)
4296 (defvar org-tbl-menu) 4546 (defvar org-tbl-menu)
4297 4547
4298 ;;;; Define the Org-mode 4548 ;;;; Define the Org-mode
4299 4549
4300 (if (and (not (keymapp outline-mode-map)) (featurep 'allout)) 4550 (if (and (not (keymapp outline-mode-map)) (featurep 'allout))
4301 (error "Conflict with outdated version of allout.el. Load org.el before allout.el, or upgrade to newer allout, for example by switching to Emacs 22.")) 4551 (error "Conflict with outdated version of allout.el. Load org.el before allout.el, or upgrade to newer allout, for example by switching to Emacs 22"))
4302 4552
4303 4553
4304 ;; We use a before-change function to check if a table might need 4554 ;; We use a before-change function to check if a table might need
4305 ;; an update. 4555 ;; an update.
4306 (defvar org-table-may-need-update t 4556 (defvar org-table-may-need-update t
4343 ;; Need to do this here because define-derived-mode sets up 4593 ;; Need to do this here because define-derived-mode sets up
4344 ;; the keymap so late. Still, it is a waste to call this each time 4594 ;; the keymap so late. Still, it is a waste to call this each time
4345 ;; we switch another buffer into org-mode. 4595 ;; we switch another buffer into org-mode.
4346 (if (featurep 'xemacs) 4596 (if (featurep 'xemacs)
4347 (when (boundp 'outline-mode-menu-heading) 4597 (when (boundp 'outline-mode-menu-heading)
4348 ;; Assume this is Greg's port, it used easymenu 4598 ;; Assume this is Greg's port, it uses easymenu
4349 (easy-menu-remove outline-mode-menu-heading) 4599 (easy-menu-remove outline-mode-menu-heading)
4350 (easy-menu-remove outline-mode-menu-show) 4600 (easy-menu-remove outline-mode-menu-show)
4351 (easy-menu-remove outline-mode-menu-hide)) 4601 (easy-menu-remove outline-mode-menu-hide))
4352 (define-key org-mode-map [menu-bar headings] 'undefined) 4602 (define-key org-mode-map [menu-bar headings] 'undefined)
4353 (define-key org-mode-map [menu-bar hide] 'undefined) 4603 (define-key org-mode-map [menu-bar hide] 'undefined)
4355 4605
4356 (org-load-modules-maybe) 4606 (org-load-modules-maybe)
4357 (easy-menu-add org-org-menu) 4607 (easy-menu-add org-org-menu)
4358 (easy-menu-add org-tbl-menu) 4608 (easy-menu-add org-tbl-menu)
4359 (org-install-agenda-files-menu) 4609 (org-install-agenda-files-menu)
4360 (if org-descriptive-links (org-add-to-invisibility-spec '(org-link))) 4610 (if org-descriptive-links (add-to-invisibility-spec '(org-link)))
4361 (org-add-to-invisibility-spec '(org-cwidth)) 4611 (add-to-invisibility-spec '(org-cwidth))
4362 (org-add-to-invisibility-spec '(org-hide-block . t)) 4612 (add-to-invisibility-spec '(org-hide-block . t))
4363 (when (featurep 'xemacs) 4613 (when (featurep 'xemacs)
4364 (org-set-local 'line-move-ignore-invisible t)) 4614 (org-set-local 'line-move-ignore-invisible t))
4365 (org-set-local 'outline-regexp org-outline-regexp) 4615 (org-set-local 'outline-regexp org-outline-regexp)
4366 (org-set-local 'outline-level 'org-outline-level) 4616 (org-set-local 'outline-level 'org-outline-level)
4367 (when (and org-ellipsis 4617 (when (and org-ellipsis
4380 (when (and org-tag-faces (not org-tags-special-faces-re)) 4630 (when (and org-tag-faces (not org-tags-special-faces-re))
4381 ;; tag faces set outside customize.... force initialization. 4631 ;; tag faces set outside customize.... force initialization.
4382 (org-set-tag-faces 'org-tag-faces org-tag-faces)) 4632 (org-set-tag-faces 'org-tag-faces org-tag-faces))
4383 ;; Calc embedded 4633 ;; Calc embedded
4384 (org-set-local 'calc-embedded-open-mode "# ") 4634 (org-set-local 'calc-embedded-open-mode "# ")
4385 (modify-syntax-entry ?# "<")
4386 (modify-syntax-entry ?@ "w") 4635 (modify-syntax-entry ?@ "w")
4387 (if org-startup-truncated (setq truncate-lines t)) 4636 (if org-startup-truncated (setq truncate-lines t))
4388 (org-set-local 'font-lock-unfontify-region-function 4637 (org-set-local 'font-lock-unfontify-region-function
4389 'org-unfontify-region) 4638 'org-unfontify-region)
4390 ;; Activate before-change-function 4639 ;; Activate before-change-function
4395 (org-add-hook 'kill-buffer-hook 'org-check-running-clock nil 'local) 4644 (org-add-hook 'kill-buffer-hook 'org-check-running-clock nil 'local)
4396 ;; Paragraphs and auto-filling 4645 ;; Paragraphs and auto-filling
4397 (org-set-autofill-regexps) 4646 (org-set-autofill-regexps)
4398 (setq indent-line-function 'org-indent-line-function) 4647 (setq indent-line-function 'org-indent-line-function)
4399 (org-update-radio-target-regexp) 4648 (org-update-radio-target-regexp)
4649 ;; Beginning/end of defun
4650 (org-set-local 'beginning-of-defun-function 'org-beginning-of-defun)
4651 (org-set-local 'end-of-defun-function 'org-end-of-defun)
4400 ;; Make sure dependence stuff works reliably, even for users who set it 4652 ;; Make sure dependence stuff works reliably, even for users who set it
4401 ;; too late :-( 4653 ;; too late :-(
4402 (if org-enforce-todo-dependencies 4654 (if org-enforce-todo-dependencies
4403 (add-hook 'org-blocker-hook 4655 (add-hook 'org-blocker-hook
4404 'org-block-todo-from-children-or-siblings-or-parent) 4656 'org-block-todo-from-children-or-siblings-or-parent)
4409 'org-block-todo-from-checkboxes) 4661 'org-block-todo-from-checkboxes)
4410 (remove-hook 'org-blocker-hook 4662 (remove-hook 'org-blocker-hook
4411 'org-block-todo-from-checkboxes)) 4663 'org-block-todo-from-checkboxes))
4412 4664
4413 ;; Comment characters 4665 ;; Comment characters
4414 ; (org-set-local 'comment-start "#") ;; FIXME: this breaks wrapping 4666 (org-set-local 'comment-start "#")
4415 (org-set-local 'comment-padding " ") 4667 (org-set-local 'comment-padding " ")
4416 4668
4417 ;; Align options lines 4669 ;; Align options lines
4418 (org-set-local 4670 (org-set-local
4419 'align-mode-rules-list 4671 'align-mode-rules-list
4443 (= (point-min) (point-max))) 4695 (= (point-min) (point-max)))
4444 (insert "# -*- mode: org -*-\n\n")) 4696 (insert "# -*- mode: org -*-\n\n"))
4445 (unless org-inhibit-startup 4697 (unless org-inhibit-startup
4446 (when org-startup-align-all-tables 4698 (when org-startup-align-all-tables
4447 (let ((bmp (buffer-modified-p))) 4699 (let ((bmp (buffer-modified-p)))
4448 (org-table-map-tables 'org-table-align) 4700 (org-table-map-tables 'org-table-align 'quietly)
4449 (set-buffer-modified-p bmp))) 4701 (set-buffer-modified-p bmp)))
4450 (when org-startup-indented 4702 (when org-startup-indented
4451 (require 'org-indent) 4703 (require 'org-indent)
4452 (org-indent-mode 1)) 4704 (org-indent-mode 1))
4453 (unless org-inhibit-startup-visibility-stuff 4705 (unless org-inhibit-startup-visibility-stuff
4470 (current-time))) 4722 (current-time)))
4471 4723
4472 ;;;; Font-Lock stuff, including the activators 4724 ;;;; Font-Lock stuff, including the activators
4473 4725
4474 (defvar org-mouse-map (make-sparse-keymap)) 4726 (defvar org-mouse-map (make-sparse-keymap))
4475 (org-defkey org-mouse-map 4727 (org-defkey org-mouse-map [mouse-2] 'org-open-at-mouse)
4476 (if (featurep 'xemacs) [button2] [mouse-2]) 'org-open-at-mouse) 4728 (org-defkey org-mouse-map [mouse-3] 'org-find-file-at-mouse)
4477 (org-defkey org-mouse-map
4478 (if (featurep 'xemacs) [button3] [mouse-3]) 'org-find-file-at-mouse)
4479 (when org-mouse-1-follows-link 4729 (when org-mouse-1-follows-link
4480 (org-defkey org-mouse-map [follow-link] 'mouse-face)) 4730 (org-defkey org-mouse-map [follow-link] 'mouse-face))
4481 (when org-tab-follows-link 4731 (when org-tab-follows-link
4482 (org-defkey org-mouse-map [(tab)] 'org-open-at-point) 4732 (org-defkey org-mouse-map [(tab)] 'org-open-at-point)
4483 (org-defkey org-mouse-map "\C-i" 'org-open-at-point)) 4733 (org-defkey org-mouse-map "\C-i" 'org-open-at-point))
4484 4734
4485 (require 'font-lock) 4735 (require 'font-lock)
4486 4736
4487 (defconst org-non-link-chars "]\t\n\r<>") 4737 (defconst org-non-link-chars "]\t\n\r<>")
4488 (defvar org-link-types '("http" "https" "ftp" "mailto" "file" "news" 4738 (defvar org-link-types '("http" "https" "ftp" "mailto" "file" "news"
4489 "shell" "elisp")) 4739 "shell" "elisp" "doi"))
4490 (defvar org-link-types-re nil 4740 (defvar org-link-types-re nil
4491 "Matches a link that has a url-like prefix like \"http:\"") 4741 "Matches a link that has a url-like prefix like \"http:\"")
4492 (defvar org-link-re-with-space nil 4742 (defvar org-link-re-with-space nil
4493 "Matches a link with spaces, optional angular brackets around it.") 4743 "Matches a link with spaces, optional angular brackets around it.")
4494 (defvar org-link-re-with-space2 nil 4744 (defvar org-link-re-with-space2 nil
4508 2: http 4758 2: http
4509 3: path 4759 3: path
4510 4: [desc] 4760 4: [desc]
4511 5: desc") 4761 5: desc")
4512 (defvar org-bracket-link-analytic-regexp++ nil 4762 (defvar org-bracket-link-analytic-regexp++ nil
4513 "Like org-bracket-link-analytic-regexp, but include coderef internal type.") 4763 "Like `org-bracket-link-analytic-regexp', but include coderef internal type.")
4514 (defvar org-any-link-re nil 4764 (defvar org-any-link-re nil
4515 "Regular expression matching any link.") 4765 "Regular expression matching any link.")
4766
4767 (defcustom org-match-sexp-depth 3
4768 "Number of stacked braces for sub/superscript matching.
4769 This has to be set before loading org.el to be effective."
4770 :group 'org-export-translation ; ??????????????????????????/
4771 :type 'integer)
4772
4773 (defun org-create-multibrace-regexp (left right n)
4774 "Create a regular expression which will match a balanced sexp.
4775 Opening delimiter is LEFT, and closing delimiter is RIGHT, both given
4776 as single character strings.
4777 The regexp returned will match the entire expression including the
4778 delimiters. It will also define a single group which contains the
4779 match except for the outermost delimiters. The maximum depth of
4780 stacked delimiters is N. Escaping delimiters is not possible."
4781 (let* ((nothing (concat "[^" left right "]*?"))
4782 (or "\\|")
4783 (re nothing)
4784 (next (concat "\\(?:" nothing left nothing right "\\)+" nothing)))
4785 (while (> n 1)
4786 (setq n (1- n)
4787 re (concat re or next)
4788 next (concat "\\(?:" nothing left next right "\\)+" nothing)))
4789 (concat left "\\(" re "\\)" right)))
4790
4791 (defvar org-match-substring-regexp
4792 (concat
4793 "\\([^\\]\\)\\([_^]\\)\\("
4794 "\\(" (org-create-multibrace-regexp "{" "}" org-match-sexp-depth) "\\)"
4795 "\\|"
4796 "\\(" (org-create-multibrace-regexp "(" ")" org-match-sexp-depth) "\\)"
4797 "\\|"
4798 "\\(\\(?:\\*\\|[-+]?[^-+*!@#$%^_ \t\r\n,:\"?<>~;./{}=()]+\\)\\)\\)")
4799 "The regular expression matching a sub- or superscript.")
4800
4801 (defvar org-match-substring-with-braces-regexp
4802 (concat
4803 "\\([^\\]\\)\\([_^]\\)\\("
4804 "\\(" (org-create-multibrace-regexp "{" "}" org-match-sexp-depth) "\\)"
4805 "\\)")
4806 "The regular expression matching a sub- or superscript, forcing braces.")
4516 4807
4517 (defun org-make-link-regexps () 4808 (defun org-make-link-regexps ()
4518 "Update the link regular expressions. 4809 "Update the link regular expressions.
4519 This should be called after the variable `org-link-types' has changed." 4810 This should be called after the variable `org-link-types' has changed."
4520 (setq org-link-types-re 4811 (setq org-link-types-re
4616 (nth 1 a)) 4907 (nth 1 a))
4617 (and (nth 4 a) 4908 (and (nth 4 a)
4618 (org-remove-flyspell-overlays-in 4909 (org-remove-flyspell-overlays-in
4619 (match-beginning 0) (match-end 0))) 4910 (match-beginning 0) (match-end 0)))
4620 (add-text-properties (match-beginning 2) (match-end 2) 4911 (add-text-properties (match-beginning 2) (match-end 2)
4621 '(font-lock-multiline t)) 4912 '(font-lock-multiline t org-emphasis t))
4622 (when org-hide-emphasis-markers 4913 (when org-hide-emphasis-markers
4623 (add-text-properties (match-end 4) (match-beginning 5) 4914 (add-text-properties (match-end 4) (match-beginning 5)
4624 '(invisible org-link)) 4915 '(invisible org-link))
4625 (add-text-properties (match-beginning 3) (match-end 3) 4916 (add-text-properties (match-beginning 3) (match-end 3)
4626 '(invisible org-link))))) 4917 '(invisible org-link)))))
4733 '(font-lock-fontified t face org-meta-line)) 5024 '(font-lock-fontified t face org-meta-line))
4734 (add-text-properties (match-beginning 6) (match-end 6) 5025 (add-text-properties (match-beginning 6) (match-end 6)
4735 '(font-lock-fontified t face org-block)) 5026 '(font-lock-fontified t face org-block))
4736 t) 5027 t)
4737 ((and (match-end 4) (equal dc3 "begin")) 5028 ((and (match-end 4) (equal dc3 "begin"))
4738 ;; Truely a block 5029 ;; Truly a block
4739 (setq block-type (downcase (match-string 5)) 5030 (setq block-type (downcase (match-string 5))
4740 quoting (member block-type org-protecting-blocks)) 5031 quoting (member block-type org-protecting-blocks))
4741 (when (re-search-forward 5032 (when (re-search-forward
4742 (concat "^[ \t]*#\\+end" (match-string 4) "\\>.*") 5033 (concat "^[ \t]*#\\+end" (match-string 4) "\\>.*")
4743 nil t) ;; on purpose, we look further than LIMIT 5034 nil t) ;; on purpose, we look further than LIMIT
4775 (add-text-properties 5066 (add-text-properties
4776 beg (match-end 0) 5067 beg (match-end 0)
4777 '(font-lock-fontified t face org-meta-line)) 5068 '(font-lock-fontified t face org-meta-line))
4778 t) 5069 t)
4779 ((or (member dc1 '("begin:" "end:" "caption:" "label:" 5070 ((or (member dc1 '("begin:" "end:" "caption:" "label:"
4780 "orgtbl:" "tblfm:" "tblname:")) 5071 "orgtbl:" "tblfm:" "tblname:" "result:"
5072 "results:" "source:" "srcname:" "call:"))
4781 (and (match-end 4) (equal dc3 "attr"))) 5073 (and (match-end 4) (equal dc3 "attr")))
4782 (add-text-properties 5074 (add-text-properties
4783 beg (match-end 0) 5075 beg (match-end 0)
4784 '(font-lock-fontified t face org-meta-line)) 5076 '(font-lock-fontified t face org-meta-line))
4785 t) 5077 t)
4953 (mapcar (lambda (x) (nth 1 x)) latexs))) 5245 (mapcar (lambda (x) (nth 1 x)) latexs)))
4954 (re-macros 5246 (re-macros
4955 (if org-export-with-TeX-macros 5247 (if org-export-with-TeX-macros
4956 (list (concat "\\\\" 5248 (list (concat "\\\\"
4957 (regexp-opt 5249 (regexp-opt
4958 (append (mapcar 'car (append org-entities-user 5250 (append
4959 org-entities)) 5251
4960 (if (boundp 'org-latex-entities) 5252 (delq nil
4961 (mapcar (lambda (x) 5253 (mapcar 'car-safe
4962 (or (car-safe x) x)) 5254 (append org-entities-user
4963 org-latex-entities) 5255 org-entities)))
4964 nil)) 5256 (if (boundp 'org-latex-entities)
5257 (mapcar (lambda (x)
5258 (or (car-safe x) x))
5259 org-latex-entities)
5260 nil))
4965 'words))) ; FIXME 5261 'words))) ; FIXME
4966 )) 5262 ))
4967 ;; (list "\\\\\\(?:[a-zA-Z]+\\)"))) 5263 ;; (list "\\\\\\(?:[a-zA-Z]+\\)")))
4968 (re-special (if org-export-with-special-strings 5264 (re-special (if org-export-with-special-strings
4969 (mapcar (lambda (x) (car x)) 5265 (mapcar (lambda (x) (car x))
4998 (add-text-properties (+ d (match-beginning 0)) (match-end 0) 5294 (add-text-properties (+ d (match-beginning 0)) (match-end 0)
4999 '(font-lock-multiline t))))) 5295 '(font-lock-multiline t)))))
5000 rtn))) 5296 rtn)))
5001 5297
5002 (defun org-restart-font-lock () 5298 (defun org-restart-font-lock ()
5003 "Restart font-lock-mode, to force refontification." 5299 "Restart `font-lock-mode', to force refontification."
5004 (when (and (boundp 'font-lock-mode) font-lock-mode) 5300 (when (and (boundp 'font-lock-mode) font-lock-mode)
5005 (font-lock-mode -1) 5301 (font-lock-mode -1)
5006 (font-lock-mode 1))) 5302 (font-lock-mode 1)))
5007 5303
5008 (defun org-all-targets (&optional radio) 5304 (defun org-all-targets (&optional radio)
5043 t))) 5339 t)))
5044 5340
5045 (defun org-outline-level () 5341 (defun org-outline-level ()
5046 "Compute the outline level of the heading at point. 5342 "Compute the outline level of the heading at point.
5047 This function assumes that the cursor is at the beginning of a line matched 5343 This function assumes that the cursor is at the beginning of a line matched
5048 by outline-regexp. Otherwise it returns garbage. 5344 by `outline-regexp'. Otherwise it returns garbage.
5049 If this is called at a normal headline, the level is the number of stars. 5345 If this is called at a normal headline, the level is the number of stars.
5050 Use `org-reduced-level' to remove the effect of `org-odd-levels'. 5346 Use `org-reduced-level' to remove the effect of `org-odd-levels'.
5051 For plain list items, if they are matched by `outline-regexp', this returns 5347 For plain list items, if they are matched by `outline-regexp', this returns
5052 1000 plus the line indentation." 5348 1000 plus the line indentation."
5053 (save-excursion 5349 (save-excursion
5143 ;; ARCHIVEd headings 5439 ;; ARCHIVEd headings
5144 (list (concat "^\\*+ \\(.*:" org-archive-tag ":.*\\)") 5440 (list (concat "^\\*+ \\(.*:" org-archive-tag ":.*\\)")
5145 '(1 'org-archived prepend)) 5441 '(1 'org-archived prepend))
5146 ;; Specials 5442 ;; Specials
5147 '(org-do-latex-and-special-faces) 5443 '(org-do-latex-and-special-faces)
5444 '(org-fontify-entities)
5445 '(org-raise-scripts)
5148 ;; Code 5446 ;; Code
5149 '(org-activate-code (1 'org-code t)) 5447 '(org-activate-code (1 'org-code t))
5150 ;; COMMENT 5448 ;; COMMENT
5151 (list (concat "^\\*+[ \t]+\\<\\(" org-comment-string 5449 (list (concat "^\\*+[ \t]+\\<\\(" org-comment-string
5152 "\\|" org-quote-string "\\)\\>") 5450 "\\|" org-quote-string "\\)\\>")
5160 (org-set-local 'org-font-lock-keywords org-font-lock-extra-keywords) 5458 (org-set-local 'org-font-lock-keywords org-font-lock-extra-keywords)
5161 (org-set-local 'font-lock-defaults 5459 (org-set-local 'font-lock-defaults
5162 '(org-font-lock-keywords t nil nil backward-paragraph)) 5460 '(org-font-lock-keywords t nil nil backward-paragraph))
5163 (kill-local-variable 'font-lock-keywords) nil)) 5461 (kill-local-variable 'font-lock-keywords) nil))
5164 5462
5463 (defun org-toggle-pretty-entities ()
5464 "Toggle the composition display of entities as UTF8 characters."
5465 (interactive)
5466 (org-set-local 'org-pretty-entities (not org-pretty-entities))
5467 (org-restart-font-lock)
5468 (if org-pretty-entities
5469 (message "Entities are displayed as UTF8 characers")
5470 (save-restriction
5471 (widen)
5472 (decompose-region (point-min) (point-max))
5473 (message "Entities are displayed plain"))))
5474
5475 (defun org-fontify-entities (limit)
5476 "Find an entity to fontify."
5477 (let (ee)
5478 (when org-pretty-entities
5479 (catch 'match
5480 (while (re-search-forward
5481 "\\\\\\([a-zA-Z][a-zA-Z0-9]*\\)\\($\\|[^[:alnum:]\n]\\)"
5482 limit t)
5483 (if (and (not (org-in-indented-comment-line))
5484 (setq ee (org-entity-get (match-string 1)))
5485 (= (length (nth 6 ee)) 1))
5486 (progn
5487 (add-text-properties
5488 (match-beginning 0) (match-end 1)
5489 (list 'font-lock-fontified t))
5490 (compose-region (match-beginning 0) (match-end 1)
5491 (nth 6 ee) nil)
5492 (backward-char 1)
5493 (throw 'match t))))
5494 nil))))
5495
5165 (defun org-fontify-like-in-org-mode (s &optional odd-levels) 5496 (defun org-fontify-like-in-org-mode (s &optional odd-levels)
5166 "Fontify string S like in Org-mode" 5497 "Fontify string S like in Org-mode."
5167 (with-temp-buffer 5498 (with-temp-buffer
5168 (insert s) 5499 (insert s)
5169 (let ((org-odd-levels-only odd-levels)) 5500 (let ((org-odd-levels-only odd-levels))
5170 (org-mode) 5501 (org-mode)
5171 (font-lock-fontify-buffer) 5502 (font-lock-fontify-buffer)
5236 (font-lock-default-unfontify-region beg end) 5567 (font-lock-default-unfontify-region beg end)
5237 (let* ((buffer-undo-list t) 5568 (let* ((buffer-undo-list t)
5238 (inhibit-read-only t) (inhibit-point-motion-hooks t) 5569 (inhibit-read-only t) (inhibit-point-motion-hooks t)
5239 (inhibit-modification-hooks t) 5570 (inhibit-modification-hooks t)
5240 deactivate-mark buffer-file-name buffer-file-truename) 5571 deactivate-mark buffer-file-name buffer-file-truename)
5572 (decompose-region beg end)
5241 (remove-text-properties 5573 (remove-text-properties
5242 beg end 5574 beg end
5243 (if org-indent-mode 5575 (if org-indent-mode
5244 ;; also remove line-prefix and wrap-prefix properties 5576 ;; also remove line-prefix and wrap-prefix properties
5245 '(mouse-face t keymap t org-linked-text t 5577 '(mouse-face t keymap t org-linked-text t
5246 invisible t intangible t 5578 invisible t intangible t
5247 line-prefix t wrap-prefix t 5579 line-prefix t wrap-prefix t
5248 org-no-flyspell t) 5580 org-no-flyspell t org-emphasis t)
5249 '(mouse-face t keymap t org-linked-text t 5581 '(mouse-face t keymap t org-linked-text t
5250 invisible t intangible t 5582 invisible t intangible t
5251 org-no-flyspell t))))) 5583 org-no-flyspell t org-emphasis t)))
5584 (org-remove-font-lock-display-properties beg end)))
5585
5586 (defconst org-script-display '(((raise -0.3) (height 0.7))
5587 ((raise 0.3) (height 0.7))
5588 ((raise -0.5))
5589 ((raise 0.5)))
5590 "Display properties for showing superscripts and subscripts.")
5591
5592 (defun org-remove-font-lock-display-properties (beg end)
5593 "Remove specific display properties that have been added by font lock.
5594 The will remove the raise properties that are used to show superscripts
5595 and subscripts."
5596 (let (next prop)
5597 (while (< beg end)
5598 (setq next (next-single-property-change beg 'display nil end)
5599 prop (get-text-property beg 'display))
5600 (if (member prop org-script-display)
5601 (put-text-property beg next 'display nil))
5602 (setq beg next))))
5603
5604 (defun org-raise-scripts (limit)
5605 "Add raise properties to sub/superscripts."
5606 (when (and org-pretty-entities org-pretty-entities-include-sub-superscripts)
5607 (if (re-search-forward
5608 (if (eq org-use-sub-superscripts t)
5609 org-match-substring-regexp
5610 org-match-substring-with-braces-regexp)
5611 limit t)
5612 (let* ((pos (point)) table-p comment-p
5613 (mpos (match-beginning 3))
5614 (emph-p (get-text-property mpos 'org-emphasis))
5615 (link-p (get-text-property mpos 'mouse-face))
5616 (keyw-p (eq 'org-special-keyword (get-text-property mpos 'face))))
5617 (goto-char (point-at-bol))
5618 (setq table-p (org-looking-at-p org-table-dataline-regexp)
5619 comment-p (org-looking-at-p "[ \t]*#"))
5620 (goto-char pos)
5621 ;; FIXME: Should we go back one character here, for a_b^c
5622 ;; (goto-char (1- pos)) ;????????????????????
5623 (if (or comment-p emph-p link-p keyw-p)
5624 t
5625 (put-text-property (match-beginning 3) (match-end 0)
5626 'display
5627 (if (equal (char-after (match-beginning 2)) ?^)
5628 (nth (if table-p 3 1) org-script-display)
5629 (nth (if table-p 2 0) org-script-display)))
5630 (add-text-properties (match-beginning 2) (match-end 2)
5631 (list 'invisible t
5632 'org-dwidth t 'org-dwidth-n 1))
5633 (if (and (eq (char-after (match-beginning 3)) ?{)
5634 (eq (char-before (match-end 3)) ?}))
5635 (progn
5636 (add-text-properties
5637 (match-beginning 3) (1+ (match-beginning 3))
5638 (list 'invisible t 'org-dwidth t 'org-dwidth-n 1))
5639 (add-text-properties
5640 (1- (match-end 3)) (match-end 3)
5641 (list 'invisible t 'org-dwidth t 'org-dwidth-n 1))))
5642 t)))))
5252 5643
5253 ;;;; Visibility cycling, including org-goto and indirect buffer 5644 ;;;; Visibility cycling, including org-goto and indirect buffer
5254 5645
5255 ;;; Cycling 5646 ;;; Cycling
5256 5647
5293 If there is no subtree, switch directly from CHILDREN to FOLDED. 5684 If there is no subtree, switch directly from CHILDREN to FOLDED.
5294 5685
5295 - When point is at the beginning of an empty headline and the variable 5686 - When point is at the beginning of an empty headline and the variable
5296 `org-cycle-level-after-item/entry-creation' is set, cycle the level 5687 `org-cycle-level-after-item/entry-creation' is set, cycle the level
5297 of the headline by demoting and promoting it to likely levels. This 5688 of the headline by demoting and promoting it to likely levels. This
5298 speeds up creation document structure by presing TAB once or several 5689 speeds up creation document structure by pressing TAB once or several
5299 times right after creating a new headline. 5690 times right after creating a new headline.
5300 5691
5301 - When there is a numeric prefix, go up to a heading with level ARG, do 5692 - When there is a numeric prefix, go up to a heading with level ARG, do
5302 a `show-subtree' and return to the previous cursor position. If ARG 5693 a `show-subtree' and return to the previous cursor position. If ARG
5303 is negative, go up that many levels. 5694 is negative, go up that many levels.
5471 (get-char-property (1- (point)) 'invisible)) 5862 (get-char-property (1- (point)) 'invisible))
5472 (beginning-of-line 2)) 5863 (beginning-of-line 2))
5473 (while (and (not (eobp)) ;; this is like `next-line' 5864 (while (and (not (eobp)) ;; this is like `next-line'
5474 (get-char-property (1- (point)) 'invisible)) 5865 (get-char-property (1- (point)) 'invisible))
5475 (goto-char (next-single-char-property-change (point) 'invisible)) 5866 (goto-char (next-single-char-property-change (point) 'invisible))
5476 ;;;??? (or (bolp) (beginning-of-line 2))))
5477 (and (eolp) (beginning-of-line 2)))) 5867 (and (eolp) (beginning-of-line 2))))
5478 (setq eol (point))) 5868 (setq eol (point)))
5479 (outline-end-of-heading) (setq eoh (point)) 5869 (outline-end-of-heading) (setq eoh (point))
5480 (save-excursion 5870 (save-excursion
5481 (outline-next-heading) 5871 (outline-next-heading)
5533 (run-hook-with-args 'org-cycle-hook 'folded))))) 5923 (run-hook-with-args 'org-cycle-hook 'folded)))))
5534 5924
5535 ;;;###autoload 5925 ;;;###autoload
5536 (defun org-global-cycle (&optional arg) 5926 (defun org-global-cycle (&optional arg)
5537 "Cycle the global visibility. For details see `org-cycle'. 5927 "Cycle the global visibility. For details see `org-cycle'.
5538 With C-u prefix arg, switch to startup visibility. 5928 With \\[universal-argument] prefix arg, switch to startup visibility.
5539 With a numeric prefix, show all headlines up to that level." 5929 With a numeric prefix, show all headlines up to that level."
5540 (interactive "P") 5930 (interactive "P")
5541 (let ((org-cycle-include-plain-lists 5931 (let ((org-cycle-include-plain-lists
5542 (if (org-mode-p) org-cycle-include-plain-lists nil))) 5932 (if (org-mode-p) org-cycle-include-plain-lists nil)))
5543 (cond 5933 (cond
5562 (unless (eq org-startup-folded 'showeverything) 5952 (unless (eq org-startup-folded 'showeverything)
5563 (if org-hide-block-startup (org-hide-block-all)) 5953 (if org-hide-block-startup (org-hide-block-all))
5564 (org-set-visibility-according-to-property 'no-cleanup) 5954 (org-set-visibility-according-to-property 'no-cleanup)
5565 (org-cycle-hide-archived-subtrees 'all) 5955 (org-cycle-hide-archived-subtrees 'all)
5566 (org-cycle-hide-drawers 'all) 5956 (org-cycle-hide-drawers 'all)
5567 (org-cycle-show-empty-lines 'all))) 5957 (org-cycle-show-empty-lines t)))
5568 5958
5569 (defun org-set-visibility-according-to-property (&optional no-cleanup) 5959 (defun org-set-visibility-according-to-property (&optional no-cleanup)
5570 "Switch subtree visibilities according to :VISIBILITY: property." 5960 "Switch subtree visibilities according to :VISIBILITY: property."
5571 (interactive) 5961 (interactive)
5572 (let (org-show-entry-below state) 5962 (let (org-show-entry-below state)
5646 6036
5647 (defun org-remove-empty-overlays-at (pos) 6037 (defun org-remove-empty-overlays-at (pos)
5648 "Remove outline overlays that do not contain non-white stuff." 6038 "Remove outline overlays that do not contain non-white stuff."
5649 (mapc 6039 (mapc
5650 (lambda (o) 6040 (lambda (o)
5651 (and (eq 'outline (org-overlay-get o 'invisible)) 6041 (and (eq 'outline (overlay-get o 'invisible))
5652 (not (string-match "\\S-" (buffer-substring (org-overlay-start o) 6042 (not (string-match "\\S-" (buffer-substring (overlay-start o)
5653 (org-overlay-end o)))) 6043 (overlay-end o))))
5654 (org-delete-overlay o))) 6044 (delete-overlay o)))
5655 (org-overlays-at pos))) 6045 (overlays-at pos)))
5656 6046
5657 (defun org-clean-visibility-after-subtree-move () 6047 (defun org-clean-visibility-after-subtree-move ()
5658 "Fix visibility issues after moving a subtree." 6048 "Fix visibility issues after moving a subtree."
5659 ;; First, find a reasonable region to look at: 6049 ;; First, find a reasonable region to look at:
5660 ;; Start two siblings above, end three below 6050 ;; Start two siblings above, end three below
5803 ;;; Saving and restoring visibility 6193 ;;; Saving and restoring visibility
5804 6194
5805 (defun org-outline-overlay-data (&optional use-markers) 6195 (defun org-outline-overlay-data (&optional use-markers)
5806 "Return a list of the locations of all outline overlays. 6196 "Return a list of the locations of all outline overlays.
5807 The are overlays with the `invisible' property value `outline'. 6197 The are overlays with the `invisible' property value `outline'.
5808 The return valus is a list of cons cells, with start and stop 6198 The return values is a list of cons cells, with start and stop
5809 positions for each overlay. 6199 positions for each overlay.
5810 If USE-MARKERS is set, return the positions as markers." 6200 If USE-MARKERS is set, return the positions as markers."
5811 (let (beg end) 6201 (let (beg end)
5812 (save-excursion 6202 (save-excursion
5813 (save-restriction 6203 (save-restriction
5814 (widen) 6204 (widen)
5815 (delq nil 6205 (delq nil
5816 (mapcar (lambda (o) 6206 (mapcar (lambda (o)
5817 (when (eq (org-overlay-get o 'invisible) 'outline) 6207 (when (eq (overlay-get o 'invisible) 'outline)
5818 (setq beg (org-overlay-start o) 6208 (setq beg (overlay-start o)
5819 end (org-overlay-end o)) 6209 end (overlay-end o))
5820 (and beg end (> end beg) 6210 (and beg end (> end beg)
5821 (if use-markers 6211 (if use-markers
5822 (cons (move-marker (make-marker) beg) 6212 (cons (move-marker (make-marker) beg)
5823 (move-marker (make-marker) end)) 6213 (move-marker (make-marker) end))
5824 (cons beg end))))) 6214 (cons beg end)))))
5825 (org-overlays-in (point-min) (point-max)))))))) 6215 (overlays-in (point-min) (point-max))))))))
5826 6216
5827 (defun org-set-outline-overlay-data (data) 6217 (defun org-set-outline-overlay-data (data)
5828 "Create visibility overlays for all positions in DATA. 6218 "Create visibility overlays for all positions in DATA.
5829 DATA should have been made by `org-outline-overlay-data'." 6219 DATA should have been made by `org-outline-overlay-data'."
5830 (let (o) 6220 (let (o)
5831 (save-excursion 6221 (save-excursion
5832 (save-restriction 6222 (save-restriction
5833 (widen) 6223 (widen)
5834 (show-all) 6224 (show-all)
5835 (mapc (lambda (c) 6225 (mapc (lambda (c)
5836 (setq o (org-make-overlay (car c) (cdr c))) 6226 (setq o (make-overlay (car c) (cdr c)))
5837 (org-overlay-put o 'invisible 'outline)) 6227 (overlay-put o 'invisible 'outline))
5838 data))))) 6228 data)))))
5839 6229
5840 (defmacro org-save-outline-visibility (use-markers &rest body) 6230 (defmacro org-save-outline-visibility (use-markers &rest body)
5841 "Save and restore outline visibility around BODY. 6231 "Save and restore outline visibility around BODY.
5842 If USE-MARKERS is non-nil, use markers for the positions. 6232 If USE-MARKERS is non-nil, use markers for the positions.
5843 This means that the buffer may change while running BODY, 6233 This means that the buffer may change while running BODY,
5844 but it also means that the buffer should stay alive 6234 but it also means that the buffer should stay alive
5845 during the operation, because otherwise all these markers will 6235 during the operation, because otherwise all these markers will
5846 point nowhere." 6236 point nowhere."
6237 (declare (indent 1))
5847 `(let ((data (org-outline-overlay-data ,use-markers))) 6238 `(let ((data (org-outline-overlay-data ,use-markers)))
5848 (unwind-protect 6239 (unwind-protect
5849 (progn 6240 (progn
5850 ,@body 6241 ,@body
5851 (org-set-outline-overlay-data data)) 6242 (org-set-outline-overlay-data data))
5866 (defvar org-hide-block-overlays nil 6257 (defvar org-hide-block-overlays nil
5867 "Overlays hiding blocks.") 6258 "Overlays hiding blocks.")
5868 (make-variable-buffer-local 'org-hide-block-overlays) 6259 (make-variable-buffer-local 'org-hide-block-overlays)
5869 6260
5870 (defun org-block-map (function &optional start end) 6261 (defun org-block-map (function &optional start end)
5871 "Call func at the head of all source blocks in the current 6262 "Call FUNCTION at the head of all source blocks in the current buffer.
5872 buffer. Optional arguments START and END can be used to limit 6263 Optional arguments START and END can be used to limit the range."
5873 the range."
5874 (let ((start (or start (point-min))) 6264 (let ((start (or start (point-min)))
5875 (end (or end (point-max)))) 6265 (end (or end (point-max))))
5876 (save-excursion 6266 (save-excursion
5877 (goto-char start) 6267 (goto-char start)
5878 (while (and (< (point) end) (re-search-forward org-block-regexp end t)) 6268 (while (and (< (point) end) (re-search-forward org-block-regexp end t))
5891 (org-show-block-all) 6281 (org-show-block-all)
5892 (org-block-map #'org-hide-block-toggle-maybe)) 6282 (org-block-map #'org-hide-block-toggle-maybe))
5893 6283
5894 (defun org-show-block-all () 6284 (defun org-show-block-all ()
5895 "Unfold all blocks in the current buffer." 6285 "Unfold all blocks in the current buffer."
5896 (mapc 'org-delete-overlay org-hide-block-overlays) 6286 (interactive)
6287 (mapc 'delete-overlay org-hide-block-overlays)
5897 (setq org-hide-block-overlays nil)) 6288 (setq org-hide-block-overlays nil))
5898 6289
5899 (defun org-hide-block-toggle-maybe () 6290 (defun org-hide-block-toggle-maybe ()
5900 "Toggle visibility of block at point." 6291 "Toggle visibility of block at point."
5901 (interactive) 6292 (interactive)
5915 (if (re-search-forward org-block-regexp nil t) 6306 (if (re-search-forward org-block-regexp nil t)
5916 (let ((start (- (match-beginning 4) 1)) ;; beginning of body 6307 (let ((start (- (match-beginning 4) 1)) ;; beginning of body
5917 (end (match-end 0)) ;; end of entire body 6308 (end (match-end 0)) ;; end of entire body
5918 ov) 6309 ov)
5919 (if (memq t (mapcar (lambda (overlay) 6310 (if (memq t (mapcar (lambda (overlay)
5920 (eq (org-overlay-get overlay 'invisible) 6311 (eq (overlay-get overlay 'invisible)
5921 'org-hide-block)) 6312 'org-hide-block))
5922 (org-overlays-at start))) 6313 (overlays-at start)))
5923 (if (or (not force) (eq force 'off)) 6314 (if (or (not force) (eq force 'off))
5924 (mapc (lambda (ov) 6315 (mapc (lambda (ov)
5925 (when (member ov org-hide-block-overlays) 6316 (when (member ov org-hide-block-overlays)
5926 (setq org-hide-block-overlays 6317 (setq org-hide-block-overlays
5927 (delq ov org-hide-block-overlays))) 6318 (delq ov org-hide-block-overlays)))
5928 (when (eq (org-overlay-get ov 'invisible) 6319 (when (eq (overlay-get ov 'invisible)
5929 'org-hide-block) 6320 'org-hide-block)
5930 (org-delete-overlay ov))) 6321 (delete-overlay ov)))
5931 (org-overlays-at start))) 6322 (overlays-at start)))
5932 (setq ov (org-make-overlay start end)) 6323 (setq ov (make-overlay start end))
5933 (org-overlay-put ov 'invisible 'org-hide-block) 6324 (overlay-put ov 'invisible 'org-hide-block)
5934 ;; make the block accessible to isearch 6325 ;; make the block accessible to isearch
5935 (org-overlay-put 6326 (overlay-put
5936 ov 'isearch-open-invisible 6327 ov 'isearch-open-invisible
5937 (lambda (ov) 6328 (lambda (ov)
5938 (when (member ov org-hide-block-overlays) 6329 (when (member ov org-hide-block-overlays)
5939 (setq org-hide-block-overlays 6330 (setq org-hide-block-overlays
5940 (delq ov org-hide-block-overlays))) 6331 (delq ov org-hide-block-overlays)))
5941 (when (eq (org-overlay-get ov 'invisible) 6332 (when (eq (overlay-get ov 'invisible)
5942 'org-hide-block) 6333 'org-hide-block)
5943 (org-delete-overlay ov)))) 6334 (delete-overlay ov))))
5944 (push ov org-hide-block-overlays))) 6335 (push ov org-hide-block-overlays)))
5945 (error "Not looking at a source block")))) 6336 (error "Not looking at a source block"))))
5946 6337
5947 ;; org-tab-after-check-for-cycling-hook 6338 ;; org-tab-after-check-for-cycling-hook
5948 (add-hook 'org-tab-first-hook 'org-hide-block-toggle-maybe) 6339 (add-hook 'org-tab-first-hook 'org-hide-block-toggle-maybe)
6155 "Create indirect buffer and narrow it to current subtree. 6546 "Create indirect buffer and narrow it to current subtree.
6156 With numerical prefix ARG, go up to this level and then take that tree. 6547 With numerical prefix ARG, go up to this level and then take that tree.
6157 If ARG is negative, go up that many levels. 6548 If ARG is negative, go up that many levels.
6158 If `org-indirect-buffer-display' is not `new-frame', the command removes the 6549 If `org-indirect-buffer-display' is not `new-frame', the command removes the
6159 indirect buffer previously made with this command, to avoid proliferation of 6550 indirect buffer previously made with this command, to avoid proliferation of
6160 indirect buffers. However, when you call the command with a `C-u' prefix, or 6551 indirect buffers. However, when you call the command with a \
6552 \\[universal-argument] prefix, or
6161 when `org-indirect-buffer-display' is `new-frame', the last buffer 6553 when `org-indirect-buffer-display' is `new-frame', the last buffer
6162 is kept so that you can work with several indirect buffers at the same time. 6554 is kept so that you can work with several indirect buffers at the same time.
6163 If `org-indirect-buffer-display' is `dedicated-frame', the C-u prefix also 6555 If `org-indirect-buffer-display' is `dedicated-frame', the \
6556 \\[universal-argument] prefix also
6164 requests that a new frame be made for the new buffer, so that the dedicated 6557 requests that a new frame be made for the new buffer, so that the dedicated
6165 frame is not changed." 6558 frame is not changed."
6166 (interactive "P") 6559 (interactive "P")
6167 (let ((cbuf (current-buffer)) 6560 (let ((cbuf (current-buffer))
6168 (cwin (selected-window)) 6561 (cwin (selected-window))
6643 (< (point) end)) 7036 (< (point) end))
6644 (not (eobp))) 7037 (not (eobp)))
6645 (funcall fun))))) 7038 (funcall fun)))))
6646 7039
6647 (defun org-fixup-indentation (diff) 7040 (defun org-fixup-indentation (diff)
6648 "Change the indentation in the current entry by DIFF 7041 "Change the indentation in the current entry by DIFF.
6649 However, if any line in the current entry has no indentation, or if it 7042 However, if any line in the current entry has no indentation, or if it
6650 would end up with no indentation after the change, nothing at all is done." 7043 would end up with no indentation after the change, nothing at all is done."
6651 (save-excursion 7044 (save-excursion
6652 (let ((end (save-excursion (outline-next-heading) 7045 (let ((end (save-excursion (outline-next-heading)
6653 (point-marker))) 7046 (point-marker)))
6681 (while (>= (setq n (1- n)) 0) 7074 (while (>= (setq n (1- n)) 0)
6682 (org-demote)) 7075 (org-demote))
6683 (end-of-line 1)))))) 7076 (end-of-line 1))))))
6684 7077
6685 (defun org-convert-to-oddeven-levels () 7078 (defun org-convert-to-oddeven-levels ()
6686 "Convert an org-mode file with only odd levels to one with odd and even levels. 7079 "Convert an org-mode file with only odd levels to one with odd/even levels.
6687 This promotes level 3 to level 2, level 5 to level 3 etc. If the file contains a 7080 This promotes level 3 to level 2, level 5 to level 3 etc. If the
6688 section with an even level, conversion would destroy the structure of the file. An error 7081 file contains a section with an even level, conversion would
6689 is signaled in this case." 7082 destroy the structure of the file. An error is signaled in this
7083 case."
6690 (interactive) 7084 (interactive)
6691 (goto-char (point-min)) 7085 (goto-char (point-min))
6692 ;; First check if there are no even levels 7086 ;; First check if there are no even levels
6693 (when (re-search-forward "^\\(\\*\\*\\)+ " nil t) 7087 (when (re-search-forward "^\\(\\*\\*\\)+ " nil t)
6694 (org-show-context t) 7088 (org-show-context t)
7023 (progn (org-back-to-heading t) (point)) 7417 (progn (org-back-to-heading t) (point))
7024 (progn (org-end-of-subtree t t) 7418 (progn (org-end-of-subtree t t)
7025 (if (org-on-heading-p) (backward-char 1)) 7419 (if (org-on-heading-p) (backward-char 1))
7026 (point)))))) 7420 (point))))))
7027 7421
7422 (eval-when-compile
7423 (defvar org-property-drawer-re))
7424
7028 (defun org-clone-subtree-with-time-shift (n &optional shift) 7425 (defun org-clone-subtree-with-time-shift (n &optional shift)
7029 "Clone the task (subtree) at point N times. 7426 "Clone the task (subtree) at point N times.
7030 The clones will be inserted as siblings. 7427 The clones will be inserted as siblings.
7031 7428
7032 In interactive use, the user will be prompted for the number of clones 7429 In interactive use, the user will be prompted for the number of
7033 to be produced, and for a time SHIFT, which may be a repeater as used 7430 clones to be produced, and for a time SHIFT, which may be a
7034 in time stamps, for example `+3d'. 7431 repeater as used in time stamps, for example `+3d'.
7035 7432
7036 When a valid repeater is given and the entry contains any time stamps, 7433 When a valid repeater is given and the entry contains any time
7037 the clones will become a sequence in time, with time stamps in the 7434 stamps, the clones will become a sequence in time, with time
7038 subtree shifted for each clone produced. If SHIFT is nil or the 7435 stamps in the subtree shifted for each clone produced. If SHIFT
7039 empty string, time stamps will be left alone. 7436 is nil or the empty string, time stamps will be left alone. The
7437 ID property of the original subtree is removed.
7040 7438
7041 If the original subtree did contain time stamps with a repeater, 7439 If the original subtree did contain time stamps with a repeater,
7042 the following will happen: 7440 the following will happen:
7043 - the repeater will be removed in each clone 7441 - the repeater will be removed in each clone
7044 - an additional clone will be produced, with the current, unshifted 7442 - an additional clone will be produced, with the current, unshifted
7048 - the start days in the repeater in the original entry will be shifted 7446 - the start days in the repeater in the original entry will be shifted
7049 to past the last clone. 7447 to past the last clone.
7050 I this way you can spell out a number of instances of a repeating task, 7448 I this way you can spell out a number of instances of a repeating task,
7051 and still retain the repeater to cover future instances of the task." 7449 and still retain the repeater to cover future instances of the task."
7052 (interactive "nNumber of clones to produce: \nsDate shift per clone (e.g. +1w, empty to copy unchanged): ") 7450 (interactive "nNumber of clones to produce: \nsDate shift per clone (e.g. +1w, empty to copy unchanged): ")
7053 (let (beg end template task 7451 (let (beg end template task idprop
7054 shift-n shift-what doshift nmin nmax (n-no-remove -1)) 7452 shift-n shift-what doshift nmin nmax (n-no-remove -1))
7055 (if (not (and (integerp n) (> n 0))) 7453 (if (not (and (integerp n) (> n 0)))
7056 (error "Invalid number of replications %s" n)) 7454 (error "Invalid number of replications %s" n))
7057 (if (and (setq doshift (and (stringp shift) (string-match "\\S-" shift))) 7455 (if (and (setq doshift (and (stringp shift) (string-match "\\S-" shift)))
7058 (not (string-match "\\`[ \t]*\\+?\\([0-9]+\\)\\([dwmy]\\)[ \t]*\\'" 7456 (not (string-match "\\`[ \t]*\\+?\\([0-9]+\\)\\([dwmy]\\)[ \t]*\\'"
7065 ("m" . month) ("y" . year)))))) 7463 ("m" . month) ("y" . year))))))
7066 (if (eq shift-what 'week) (setq shift-n (* 7 shift-n) shift-what 'day)) 7464 (if (eq shift-what 'week) (setq shift-n (* 7 shift-n) shift-what 'day))
7067 (setq nmin 1 nmax n) 7465 (setq nmin 1 nmax n)
7068 (org-back-to-heading t) 7466 (org-back-to-heading t)
7069 (setq beg (point)) 7467 (setq beg (point))
7468 (setq idprop (org-entry-get nil "ID"))
7070 (org-end-of-subtree t t) 7469 (org-end-of-subtree t t)
7071 (or (bolp) (insert "\n")) 7470 (or (bolp) (insert "\n"))
7072 (setq end (point)) 7471 (setq end (point))
7073 (setq template (buffer-substring beg end)) 7472 (setq template (buffer-substring beg end))
7074 (when (and doshift 7473 (when (and doshift
7076 (delete-region beg end) 7475 (delete-region beg end)
7077 (setq end beg) 7476 (setq end beg)
7078 (setq nmin 0 nmax (1+ nmax) n-no-remove nmax)) 7477 (setq nmin 0 nmax (1+ nmax) n-no-remove nmax))
7079 (goto-char end) 7478 (goto-char end)
7080 (loop for n from nmin to nmax do 7479 (loop for n from nmin to nmax do
7081 (if (not doshift) 7480 ;; prepare clone
7082 (setq task template) 7481 (with-temp-buffer
7083 (with-temp-buffer 7482 (insert template)
7084 (insert template) 7483 (org-mode)
7085 (org-mode) 7484 (goto-char (point-min))
7086 (goto-char (point-min)) 7485 (and idprop (if org-clone-delete-id
7486 (org-entry-delete nil "ID")
7487 (org-id-get-create t)))
7488 (while (re-search-forward org-property-drawer-re nil t)
7489 (org-remove-empty-drawer-at "PROPERTIES" (point)))
7490 (goto-char (point-min))
7491 (when doshift
7087 (while (re-search-forward org-ts-regexp-both nil t) 7492 (while (re-search-forward org-ts-regexp-both nil t)
7088 (org-timestamp-change (* n shift-n) shift-what)) 7493 (org-timestamp-change (* n shift-n) shift-what))
7089 (unless (= n n-no-remove) 7494 (unless (= n n-no-remove)
7090 (goto-char (point-min)) 7495 (goto-char (point-min))
7091 (while (re-search-forward org-ts-regexp nil t) 7496 (while (re-search-forward org-ts-regexp nil t)
7092 (save-excursion 7497 (save-excursion
7093 (goto-char (match-beginning 0)) 7498 (goto-char (match-beginning 0))
7094 (if (looking-at "<[^<>\n]+\\( +\\+[0-9]+[dwmy]\\)") 7499 (if (looking-at "<[^<>\n]+\\( +\\+[0-9]+[dwmy]\\)")
7095 (delete-region (match-beginning 1) (match-end 1)))))) 7500 (delete-region (match-beginning 1) (match-end 1)))))))
7096 (setq task (buffer-string)))) 7501 (setq task (buffer-string)))
7097 (insert task)) 7502 (insert task))
7098 (goto-char beg))) 7503 (goto-char beg)))
7099 7504
7100 ;;; Outline Sorting 7505 ;;; Outline Sorting
7101 7506
7135 7540
7136 Sorting can be alphabetically, numerically, by date/time as given by 7541 Sorting can be alphabetically, numerically, by date/time as given by
7137 a time stamp, by a property or by priority. 7542 a time stamp, by a property or by priority.
7138 7543
7139 The command prompts for the sorting type unless it has been given to the 7544 The command prompts for the sorting type unless it has been given to the
7140 function through the SORTING-TYPE argument, which needs to a character, 7545 function through the SORTING-TYPE argument, which needs to be a character,
7141 \(?n ?N ?a ?A ?t ?T ?s ?S ?d ?D ?p ?P ?r ?R ?f ?F). Here is the 7546 \(?n ?N ?a ?A ?t ?T ?s ?S ?d ?D ?p ?P ?r ?R ?f ?F). Here is the
7142 precise meaning of each character: 7547 precise meaning of each character:
7143 7548
7144 n Numerically, by converting the beginning of the entry/item to a number. 7549 n Numerically, by converting the beginning of the entry/item to a number.
7145 a Alphabetically, ignoring the TODO keyword and the priority, if any. 7550 a Alphabetically, ignoring the TODO keyword and the priority, if any.
7428 7833
7429 (defvar orgstruct-mode-map (make-sparse-keymap) 7834 (defvar orgstruct-mode-map (make-sparse-keymap)
7430 "Keymap for the minor `orgstruct-mode'.") 7835 "Keymap for the minor `orgstruct-mode'.")
7431 7836
7432 (defvar org-local-vars nil 7837 (defvar org-local-vars nil
7433 "List of local variables, for use by `orgstruct-mode'") 7838 "List of local variables, for use by `orgstruct-mode'.")
7434 7839
7435 ;;;###autoload 7840 ;;;###autoload
7436 (define-minor-mode orgstruct-mode 7841 (define-minor-mode orgstruct-mode
7437 "Toggle the minor more `orgstruct-mode'. 7842 "Toggle the minor mode `orgstruct-mode'.
7438 This mode is for using Org-mode structure commands in other modes. 7843 This mode is for using Org-mode structure commands in other
7439 The following key behave as if Org-mode was active, if the cursor 7844 modes. The following keys behave as if Org-mode were active, if
7440 is on a headline, or on a plain list item (both in the definition 7845 the cursor is on a headline, or on a plain list item (both as
7441 of Org-mode). 7846 defined by Org-mode).
7442 7847
7443 M-up Move entry/item up 7848 M-up Move entry/item up
7444 M-down Move entry/item down 7849 M-down Move entry/item down
7445 M-left Promote 7850 M-left Promote
7446 M-right Demote 7851 M-right Demote
7487 (org-set-local var (if (eq (car-safe val) 'quote) (nth 1 val) val)))) 7892 (org-set-local var (if (eq (car-safe val) 'quote) (nth 1 val) val))))
7488 org-local-vars) 7893 org-local-vars)
7489 (org-set-local 'orgstruct-is-++ t)))) 7894 (org-set-local 'orgstruct-is-++ t))))
7490 7895
7491 (defvar orgstruct-is-++ nil 7896 (defvar orgstruct-is-++ nil
7492 "Is orgstruct-mode in ++ version in the current-buffer?") 7897 "Is `orgstruct-mode' in ++ version in the current-buffer?")
7493 (make-variable-buffer-local 'orgstruct-is-++) 7898 (make-variable-buffer-local 'orgstruct-is-++)
7494 7899
7495 ;;;###autoload 7900 ;;;###autoload
7496 (defun turn-on-orgstruct++ () 7901 (defun turn-on-orgstruct++ ()
7497 "Unconditionally turn on `orgstruct++-mode'." 7902 "Unconditionally turn on `orgstruct++-mode'."
7729 If not, it must exit and return nil. 8134 If not, it must exit and return nil.
7730 If yes, it should return a non-nil value after a calling 8135 If yes, it should return a non-nil value after a calling
7731 `org-store-link-props' with a list of properties and values. 8136 `org-store-link-props' with a list of properties and values.
7732 Special properties are: 8137 Special properties are:
7733 8138
7734 :type The link prefix. like \"http\". This must be given. 8139 :type The link prefix, like \"http\". This must be given.
7735 :link The link, like \"http://www.astro.uva.nl/~dominik\". 8140 :link The link, like \"http://www.astro.uva.nl/~dominik\".
7736 This is obligatory as well. 8141 This is obligatory as well.
7737 :description Optional default description for the second pair 8142 :description Optional default description for the second pair
7738 of brackets in an Org-mode link. The user can still change 8143 of brackets in an Org-mode link. The user can still change
7739 this when inserting this link into an Org-mode buffer. 8144 this when inserting this link into an Org-mode buffer.
7815 ;; We are in the agenda, link to referenced location 8220 ;; We are in the agenda, link to referenced location
7816 (let ((m (or (get-text-property (point) 'org-hd-marker) 8221 (let ((m (or (get-text-property (point) 'org-hd-marker)
7817 (get-text-property (point) 'org-marker)))) 8222 (get-text-property (point) 'org-marker))))
7818 (when m 8223 (when m
7819 (org-with-point-at m 8224 (org-with-point-at m
7820 (call-interactively 'org-store-link))))) 8225 (if (interactive-p)
8226 (call-interactively 'org-store-link)
8227 (org-store-link nil))))))
7821 8228
7822 ((eq major-mode 'calendar-mode) 8229 ((eq major-mode 'calendar-mode)
7823 (let ((cd (calendar-cursor-to-date))) 8230 (let ((cd (calendar-cursor-to-date)))
7824 (setq link 8231 (setq link
7825 (format-time-string 8232 (format-time-string
8126 "Exclusive or." 8533 "Exclusive or."
8127 (if a (not b) b)) 8534 (if a (not b) b))
8128 8535
8129 (defun org-fixup-message-id-for-http (s) 8536 (defun org-fixup-message-id-for-http (s)
8130 "Replace special characters in a message id, so it can be used in an http query." 8537 "Replace special characters in a message id, so it can be used in an http query."
8538 (when (string-match "%" s)
8539 (setq s (mapconcat (lambda (c)
8540 (if (eq c ?%)
8541 "%25"
8542 (char-to-string c)))
8543 s "")))
8131 (while (string-match "<" s) 8544 (while (string-match "<" s)
8132 (setq s (replace-match "%3C" t t s))) 8545 (setq s (replace-match "%3C" t t s)))
8133 (while (string-match ">" s) 8546 (while (string-match ">" s)
8134 (setq s (replace-match "%3E" t t s))) 8547 (setq s (replace-match "%3E" t t s)))
8135 (while (string-match "@" s) 8548 (while (string-match "@" s)
8293 ((eq org-link-file-path-type 'relative) 8706 ((eq org-link-file-path-type 'relative)
8294 (setq path (file-relative-name path))) 8707 (setq path (file-relative-name path)))
8295 (t 8708 (t
8296 (save-match-data 8709 (save-match-data
8297 (if (string-match (concat "^" (regexp-quote 8710 (if (string-match (concat "^" (regexp-quote
8298 (file-name-as-directory 8711 (expand-file-name
8299 (expand-file-name ".")))) 8712 (file-name-as-directory
8713 default-directory))))
8300 (expand-file-name path)) 8714 (expand-file-name path))
8301 ;; We are linking a file with relative path name. 8715 ;; We are linking a file with relative path name.
8302 (setq path (substring (expand-file-name path) 8716 (setq path (substring (expand-file-name path)
8303 (match-end 0))) 8717 (match-end 0)))
8304 (setq path (abbreviate-file-name (expand-file-name path))))))) 8718 (setq path (abbreviate-file-name (expand-file-name path)))))))
8325 "Create a file link using completion." 8739 "Create a file link using completion."
8326 (let (file link) 8740 (let (file link)
8327 (setq file (read-file-name "File: ")) 8741 (setq file (read-file-name "File: "))
8328 (let ((pwd (file-name-as-directory (expand-file-name "."))) 8742 (let ((pwd (file-name-as-directory (expand-file-name ".")))
8329 (pwd1 (file-name-as-directory (abbreviate-file-name 8743 (pwd1 (file-name-as-directory (abbreviate-file-name
8330 default-directory)))) 8744 (expand-file-name ".")))))
8331 (cond 8745 (cond
8332 ((equal arg '(16)) 8746 ((equal arg '(16))
8333 (setq link (org-make-link 8747 (setq link (org-make-link
8334 "file:" 8748 "file:"
8335 (abbreviate-file-name (expand-file-name file))))) 8749 (abbreviate-file-name (expand-file-name file)))))
8563 Normally, files will be opened by an appropriate application. If the 8977 Normally, files will be opened by an appropriate application. If the
8564 optional argument IN-EMACS is non-nil, Emacs will visit the file. 8978 optional argument IN-EMACS is non-nil, Emacs will visit the file.
8565 With a double prefix argument, try to open outside of Emacs, in the 8979 With a double prefix argument, try to open outside of Emacs, in the
8566 application the system uses for this file type." 8980 application the system uses for this file type."
8567 (interactive "P") 8981 (interactive "P")
8982 ;; if in a code block, then open the block's results
8983 (unless (call-interactively #'org-babel-open-src-block-result)
8568 (org-load-modules-maybe) 8984 (org-load-modules-maybe)
8569 (move-marker org-open-link-marker (point)) 8985 (move-marker org-open-link-marker (point))
8570 (setq org-window-config-before-follow-link (current-window-configuration)) 8986 (setq org-window-config-before-follow-link (current-window-configuration))
8571 (org-remove-occur-highlights nil nil t) 8987 (org-remove-occur-highlights nil nil t)
8572 (cond 8988 (cond
8669 9085
8670 ((member type '("http" "https" "ftp" "news")) 9086 ((member type '("http" "https" "ftp" "news"))
8671 (browse-url (concat type ":" (org-link-escape 9087 (browse-url (concat type ":" (org-link-escape
8672 path org-link-escape-chars-browser)))) 9088 path org-link-escape-chars-browser))))
8673 9089
9090 ((string= type "doi")
9091 (browse-url (concat "http://dx.doi.org/"
9092 (org-link-escape
9093 path org-link-escape-chars-browser))))
9094
8674 ((member type '("message")) 9095 ((member type '("message"))
8675 (browse-url (concat type ":" path))) 9096 (browse-url (concat type ":" path)))
8676 9097
8677 ((string= type "tags") 9098 ((string= type "tags")
8678 (org-tags-view in-emacs path)) 9099 (org-tags-view in-emacs path))
8739 (error (progn (widen) (eval cmd)))))) 9160 (error (progn (widen) (eval cmd))))))
8740 9161
8741 (t 9162 (t
8742 (browse-url-at-point))))))) 9163 (browse-url-at-point)))))))
8743 (move-marker org-open-link-marker nil) 9164 (move-marker org-open-link-marker nil)
8744 (run-hook-with-args 'org-follow-link-hook)) 9165 (run-hook-with-args 'org-follow-link-hook)))
8745 9166
8746 (defun org-offer-links-in-entry (&optional nth zero) 9167 (defun org-offer-links-in-entry (&optional nth zero)
8747 "Offer links in the current entry and follow the selected link. 9168 "Offer links in the current entry and follow the selected link.
8748 If there is only one link, follow it immediately as well. 9169 If there is only one link, follow it immediately as well.
8749 If NTH is an integer, immediately pick the NTH link found. 9170 If NTH is an integer, immediately pick the NTH link found.
8809 ;; Add special file links that specify the way of opening 9230 ;; Add special file links that specify the way of opening
8810 9231
8811 (org-add-link-type "file+sys" 'org-open-file-with-system) 9232 (org-add-link-type "file+sys" 'org-open-file-with-system)
8812 (org-add-link-type "file+emacs" 'org-open-file-with-emacs) 9233 (org-add-link-type "file+emacs" 'org-open-file-with-emacs)
8813 (defun org-open-file-with-system (path) 9234 (defun org-open-file-with-system (path)
8814 "Open file at PATH using the system way of opeing it." 9235 "Open file at PATH using the system way of opening it."
8815 (org-open-file path 'system)) 9236 (org-open-file path 'system))
8816 (defun org-open-file-with-emacs (path) 9237 (defun org-open-file-with-emacs (path)
8817 "Open file at PATH in emacs." 9238 "Open file at PATH in Emacs."
8818 (org-open-file path 'emacs)) 9239 (org-open-file path 'emacs))
8819 (defun org-remove-file-link-modifiers () 9240 (defun org-remove-file-link-modifiers ()
8820 "Remove the file link modifiers in `file+sys:' and `file+emacs:' links." 9241 "Remove the file link modifiers in `file+sys:' and `file+emacs:' links."
8821 (goto-char (point-min)) 9242 (goto-char (point-min))
8822 (while (re-search-forward "\\<file\\+\\(sys\\|emacs\\):" nil t) 9243 (while (re-search-forward "\\<file\\+\\(sys\\|emacs\\):" nil t)
8838 "List of functions to construct the right search string for a file link. 9259 "List of functions to construct the right search string for a file link.
8839 These functions are called in turn with point at the location to 9260 These functions are called in turn with point at the location to
8840 which the link should point. 9261 which the link should point.
8841 9262
8842 A function in the hook should first test if it would like to 9263 A function in the hook should first test if it would like to
8843 handle this file type, for example by checking the major-mode or 9264 handle this file type, for example by checking the `major-mode'
8844 the file extension. If it decides not to handle this file, it 9265 or the file extension. If it decides not to handle this file, it
8845 should just return nil to give other functions a chance. If it 9266 should just return nil to give other functions a chance. If it
8846 does handle the file, it must return the search string to be used 9267 does handle the file, it must return the search string to be used
8847 when following the link. The search string will be part of the 9268 when following the link. The search string will be part of the
8848 file link, given after a double colon, and `org-open-at-point' 9269 file link, given after a double colon, and `org-open-at-point'
8849 will automatically search for it. If special measures must be 9270 will automatically search for it. If special measures must be
8860 "List of functions to execute a file search triggered by a link. 9281 "List of functions to execute a file search triggered by a link.
8861 9282
8862 Functions added to this hook must accept a single argument, the 9283 Functions added to this hook must accept a single argument, the
8863 search string that was part of the file link, the part after the 9284 search string that was part of the file link, the part after the
8864 double colon. The function must first check if it would like to 9285 double colon. The function must first check if it would like to
8865 handle this search, for example by checking the major-mode or the 9286 handle this search, for example by checking the `major-mode' or
8866 file extension. If it decides not to handle this search, it 9287 the file extension. If it decides not to handle this search, it
8867 should just return nil to give other functions a chance. If it 9288 should just return nil to give other functions a chance. If it
8868 does handle the search, it must return a non-nil value to keep 9289 does handle the search, it must return a non-nil value to keep
8869 other functions from trying. 9290 other functions from trying.
8870 9291
8871 Each function can access the current prefix argument through the 9292 Each function can access the current prefix argument through the
9133 entry for this file type, and if yes, the corresponding command is launched. 9554 entry for this file type, and if yes, the corresponding command is launched.
9134 9555
9135 If no application is found, Emacs simply visits the file. 9556 If no application is found, Emacs simply visits the file.
9136 9557
9137 With optional prefix argument IN-EMACS, Emacs will visit the file. 9558 With optional prefix argument IN-EMACS, Emacs will visit the file.
9138 With a double C-c C-u prefix arg, Org tries to avoid opening in Emacs 9559 With a double \\[universal-argument] \\[universal-argument] \
9560 prefix arg, Org tries to avoid opening in Emacs
9139 and to use an external application to visit the file. 9561 and to use an external application to visit the file.
9140 9562
9141 Optional LINE specifies a line to go to, optional SEARCH a string to 9563 Optional LINE specifies a line to go to, optional SEARCH a string
9142 search for. If LINE or SEARCH is given, but IN-EMACS is nil, it will 9564 to search for. If LINE or SEARCH is given, the file will be
9143 be assumed that org-open-file was called to open a file: link, and the 9565 opened in Emacs, unless an entry from org-file-apps that makes
9144 original link to match against org-file-apps will be reconstructed 9566 use of groups in a regexp matches.
9145 from PATH and whichever of LINE or SEARCH is given.
9146
9147 If the file does not exist, an error is thrown." 9567 If the file does not exist, an error is thrown."
9148 (let* ((file (if (equal path "") 9568 (let* ((file (if (equal path "")
9149 buffer-file-name 9569 buffer-file-name
9150 (substitute-in-file-name (expand-file-name path)))) 9570 (substitute-in-file-name (expand-file-name path))))
9151 (apps (append org-file-apps (org-default-apps))) 9571 (file-apps (append org-file-apps (org-default-apps)))
9572 (apps (org-remove-if
9573 'org-file-apps-entry-match-against-dlink-p file-apps))
9574 (apps-dlink (org-remove-if-not
9575 'org-file-apps-entry-match-against-dlink-p file-apps))
9152 (remp (and (assq 'remote apps) (org-file-remote-p file))) 9576 (remp (and (assq 'remote apps) (org-file-remote-p file)))
9153 (dirp (if remp nil (file-directory-p file))) 9577 (dirp (if remp nil (file-directory-p file)))
9154 (file (if (and dirp org-open-directory-means-index-dot-org) 9578 (file (if (and dirp org-open-directory-means-index-dot-org)
9155 (concat (file-name-as-directory file) "index.org") 9579 (concat (file-name-as-directory file) "index.org")
9156 file)) 9580 file))
9178 (setq cmd (cdr (assoc 'system apps)))) 9602 (setq cmd (cdr (assoc 'system apps))))
9179 (in-emacs (setq cmd 'emacs)) 9603 (in-emacs (setq cmd 'emacs))
9180 (t 9604 (t
9181 (setq cmd (or (and remp (cdr (assoc 'remote apps))) 9605 (setq cmd (or (and remp (cdr (assoc 'remote apps)))
9182 (and dirp (cdr (assoc 'directory apps))) 9606 (and dirp (cdr (assoc 'directory apps)))
9183 ;; if we find a match in org-file-apps, store the match 9607 ; first, try matching against apps-dlink
9184 ;; data for later 9608 ; if we get a match here, store the match data for later
9185 (let* ((re-list1 (org-apps-regexp-alist apps nil)) 9609 (let ((match (assoc-default dlink apps-dlink
9186 (re-list2 9610 'string-match)))
9187 (if a-m-a-p 9611 (if match
9188 (org-apps-regexp-alist apps a-m-a-p)
9189 re-list1))
9190 (private-match
9191 (assoc-default dlink re-list1 'string-match))
9192 (general-match
9193 (assoc-default dfile re-list2 'string-match)))
9194 (if private-match
9195 (progn (setq link-match-data (match-data)) 9612 (progn (setq link-match-data (match-data))
9196 private-match) 9613 match)
9197 general-match)) 9614 (progn (setq in-emacs (or in-emacs line search))
9615 nil))) ; if we have no match in apps-dlink,
9616 ; always open the file in emacs if line or search
9617 ; is given (for backwards compatibility)
9618 (assoc-default dfile (org-apps-regexp-alist apps a-m-a-p)
9619 'string-match)
9198 (cdr (assoc ext apps)) 9620 (cdr (assoc ext apps))
9199 (cdr (assoc t apps)))))) 9621 (cdr (assoc t apps))))))
9200 (when (eq cmd 'system) 9622 (when (eq cmd 'system)
9201 (setq cmd (cdr (assoc 'system apps)))) 9623 (setq cmd (cdr (assoc 'system apps))))
9202 (when (eq cmd 'default) 9624 (when (eq cmd 'default)
9222 (setq cmd (replace-match 9644 (setq cmd (replace-match
9223 (save-match-data 9645 (save-match-data
9224 (shell-quote-argument 9646 (shell-quote-argument
9225 (convert-standard-filename file))) 9647 (convert-standard-filename file)))
9226 t t cmd))) 9648 t t cmd)))
9649
9227 ;; Replace "%1", "%2" etc. in command with group matches from regex 9650 ;; Replace "%1", "%2" etc. in command with group matches from regex
9228 (save-match-data 9651 (save-match-data
9229 (let ((match-index 1) 9652 (let ((match-index 1)
9230 (number-of-groups (- (/ (length link-match-data) 2) 1))) 9653 (number-of-groups (- (/ (length link-match-data) 2) 1)))
9231 (set-match-data link-match-data) 9654 (set-match-data link-match-data)
9255 (and (org-mode-p) (eq old-mode 'org-mode) 9678 (and (org-mode-p) (eq old-mode 'org-mode)
9256 (or (not (equal old-buffer (current-buffer))) 9679 (or (not (equal old-buffer (current-buffer)))
9257 (not (equal old-pos (point)))) 9680 (not (equal old-pos (point))))
9258 (org-mark-ring-push old-pos old-buffer)))) 9681 (org-mark-ring-push old-pos old-buffer))))
9259 9682
9683 (defun org-file-apps-entry-match-against-dlink-p (entry)
9684 "This function returns non-nil if `entry' uses a regular
9685 expression which should be matched against the whole link by
9686 org-open-file.
9687
9688 It assumes that is the case when the entry uses a regular
9689 expression which has at least one grouping construct and the
9690 action is either a lisp form or a command string containing
9691 '%1', i.e. using at least one subexpression match as a
9692 parameter."
9693 (let ((selector (car entry))
9694 (action (cdr entry)))
9695 (if (stringp selector)
9696 (and (> (regexp-opt-depth selector) 0)
9697 (or (and (stringp action)
9698 (string-match "%[0-9]" action))
9699 (consp action)))
9700 nil)))
9701
9260 (defun org-default-apps () 9702 (defun org-default-apps ()
9261 "Return the default applications for this operating system." 9703 "Return the default applications for this operating system."
9262 (cond 9704 (cond
9263 ((eq system-type 'darwin) 9705 ((eq system-type 'darwin)
9264 org-file-apps-defaults-macosx) 9706 org-file-apps-defaults-macosx)
9278 (mapcar (lambda (x) 9720 (mapcar (lambda (x)
9279 (if (not (stringp (car x))) 9721 (if (not (stringp (car x)))
9280 nil 9722 nil
9281 (if (string-match "\\W" (car x)) 9723 (if (string-match "\\W" (car x))
9282 x 9724 x
9283 (cons (concat "\\." (car x) "\\(::.*\\)?\\'") 9725 (cons (concat "\\." (car x) "\\'") (cdr x)))))
9284 (cdr x)))))
9285 list)) 9726 list))
9286 (if add-auto-mode 9727 (if add-auto-mode
9287 (mapcar (lambda (x) (cons (car x) 'emacs)) auto-mode-alist)))) 9728 (mapcar (lambda (x) (cons (car x) 'emacs)) auto-mode-alist))))
9288 9729
9289 (defvar ange-ftp-name-format) ; to silence the XEmacs compiler. 9730 (defvar ange-ftp-name-format) ; to silence the XEmacs compiler.
9330 "The list of refile targets, created by `org-refile'.") 9771 "The list of refile targets, created by `org-refile'.")
9331 9772
9332 (defvar org-agenda-new-buffers nil 9773 (defvar org-agenda-new-buffers nil
9333 "Buffers created to visit agenda files.") 9774 "Buffers created to visit agenda files.")
9334 9775
9776 (defvar org-refile-cache nil
9777 "Cache for refile targets.")
9778
9779
9780 (defvar org-refile-markers nil
9781 "All the markers used for caching refile locations.")
9782
9783 (defun org-refile-marker (pos)
9784 "Get a new refile marker, but only if caching is in use."
9785 (if (not org-refile-use-cache)
9786 pos
9787 (let ((m (make-marker)))
9788 (move-marker m pos)
9789 (push m org-refile-markers)
9790 m)))
9791
9792 (defun org-refile-cache-clear ()
9793 "Clear the refile cache and disable all the markers."
9794 (mapc (lambda (m) (move-marker m nil)) org-refile-markers)
9795 (setq org-refile-markers nil)
9796 (setq org-refile-cache nil)
9797 (message "Refile cache has been cleared"))
9798
9799 (defun org-refile-cache-check-set (set)
9800 "Check if all the markers in the cache still have live buffers."
9801 (let (marker)
9802 (catch 'exit
9803 (while (and set (setq marker (nth 3 (pop set))))
9804 ;; if org-refile-use-outline-path is 'file, marker may be nil
9805 (when (and marker (null (marker-buffer marker)))
9806 (message "not found") (sit-for 3)
9807 (throw 'exit nil)))
9808 t)))
9809
9810 (defun org-refile-cache-put (set &rest identifiers)
9811 "Push the refile targets SET into the cache, under IDENTIFIERS."
9812 (let* ((key (sha1 (prin1-to-string identifiers)))
9813 (entry (assoc key org-refile-cache)))
9814 (if entry
9815 (setcdr entry set)
9816 (push (cons key set) org-refile-cache))))
9817
9818 (defun org-refile-cache-get (&rest identifiers)
9819 "Retrieve the cached value for refile targets given by IDENTIFIERS."
9820 (cond
9821 ((not org-refile-cache) nil)
9822 ((not org-refile-use-cache) (org-refile-cache-clear) nil)
9823 (t
9824 (let ((set (cdr (assoc (sha1 (prin1-to-string identifiers))
9825 org-refile-cache))))
9826 (and set (org-refile-cache-check-set set) set)))))
9827
9335 (defun org-get-refile-targets (&optional default-buffer) 9828 (defun org-get-refile-targets (&optional default-buffer)
9336 "Produce a table with refile targets." 9829 "Produce a table with refile targets."
9337 (let ((case-fold-search nil) 9830 (let ((case-fold-search nil)
9338 ;; otherwise org confuses "TODO" as a kw and "Todo" as a word 9831 ;; otherwise org confuses "TODO" as a kw and "Todo" as a word
9339 (entries (or org-refile-targets '((nil . (:level . 1))))) 9832 (entries (or org-refile-targets '((nil . (:level . 1)))))
9340 targets txt re files f desc descre fast-path-p level pos0) 9833 targets tgs txt re files f desc descre fast-path-p level pos0)
9341 (message "Getting targets...") 9834 (message "Getting targets...")
9342 (with-current-buffer (or default-buffer (current-buffer)) 9835 (with-current-buffer (or default-buffer (current-buffer))
9343 (while (setq entry (pop entries)) 9836 (while (setq entry (pop entries))
9344 (setq files (car entry) desc (cdr entry)) 9837 (setq files (car entry) desc (cdr entry))
9345 (setq fast-path-p nil) 9838 (setq fast-path-p nil)
9374 "\\}[ \t]"))) 9867 "\\}[ \t]")))
9375 (t (error "Bad refiling target description %s" desc))) 9868 (t (error "Bad refiling target description %s" desc)))
9376 (while (setq f (pop files)) 9869 (while (setq f (pop files))
9377 (with-current-buffer 9870 (with-current-buffer
9378 (if (bufferp f) f (org-get-agenda-file-buffer f)) 9871 (if (bufferp f) f (org-get-agenda-file-buffer f))
9379 (if (bufferp f) (setq f (buffer-file-name (buffer-base-buffer f)))) 9872 (or
9380 (setq f (and f (expand-file-name f))) 9873 (setq tgs (org-refile-cache-get (buffer-file-name) descre))
9381 (if (eq org-refile-use-outline-path 'file) 9874 (progn
9382 (push (list (file-name-nondirectory f) f nil nil) targets)) 9875 (if (bufferp f) (setq f (buffer-file-name
9383 (save-excursion 9876 (buffer-base-buffer f))))
9384 (save-restriction 9877 (setq f (and f (expand-file-name f)))
9385 (widen) 9878 (if (eq org-refile-use-outline-path 'file)
9386 (goto-char (point-min)) 9879 (push (list (file-name-nondirectory f) f nil nil) tgs))
9387 (while (re-search-forward descre nil t) 9880 (save-excursion
9388 (goto-char (setq pos0 (point-at-bol))) 9881 (save-restriction
9389 (catch 'next 9882 (widen)
9390 (when org-refile-target-verify-function 9883 (goto-char (point-min))
9391 (save-match-data 9884 (while (re-search-forward descre nil t)
9392 (or (funcall org-refile-target-verify-function) 9885 (goto-char (setq pos0 (point-at-bol)))
9393 (throw 'next t)))) 9886 (catch 'next
9394 (when (looking-at org-complex-heading-regexp) 9887 (when org-refile-target-verify-function
9395 (setq level (org-reduced-level (- (match-end 1) (match-beginning 1))) 9888 (save-match-data
9396 txt (org-link-display-format (match-string 4)) 9889 (or (funcall org-refile-target-verify-function)
9397 re (concat "^" (regexp-quote 9890 (throw 'next t))))
9398 (buffer-substring (match-beginning 1) 9891 (when (looking-at org-complex-heading-regexp)
9399 (match-end 4))))) 9892 (setq level (org-reduced-level
9400 (if (match-end 5) (setq re (concat re "[ \t]+" 9893 (- (match-end 1) (match-beginning 1)))
9401 (regexp-quote 9894 txt (org-link-display-format (match-string 4))
9402 (match-string 5))))) 9895 re (concat "^" (regexp-quote
9403 (setq re (concat re "[ \t]*$")) 9896 (buffer-substring
9404 (when org-refile-use-outline-path 9897 (match-beginning 1)
9405 (setq txt (mapconcat 'org-protect-slash 9898 (match-end 4)))))
9406 (append 9899 (if (match-end 5) (setq re (concat
9407 (if (eq org-refile-use-outline-path 'file) 9900 re "[ \t]+"
9408 (list (file-name-nondirectory 9901 (regexp-quote
9409 (buffer-file-name (buffer-base-buffer)))) 9902 (match-string 5)))))
9410 (if (eq org-refile-use-outline-path 'full-file-path) 9903 (setq re (concat re "[ \t]*$"))
9411 (list (buffer-file-name (buffer-base-buffer))))) 9904 (when org-refile-use-outline-path
9412 (org-get-outline-path fast-path-p level txt) 9905 (setq txt (mapconcat
9413 (list txt)) 9906 'org-protect-slash
9414 "/"))) 9907 (append
9415 (push (list txt f re (point)) targets))) 9908 (if (eq org-refile-use-outline-path
9416 (when (= (point) pos0) 9909 'file)
9417 ;; verification function has not moved point 9910 (list (file-name-nondirectory
9418 (goto-char (point-at-eol)))))))))) 9911 (buffer-file-name
9912 (buffer-base-buffer))))
9913 (if (eq org-refile-use-outline-path
9914 'full-file-path)
9915 (list (buffer-file-name
9916 (buffer-base-buffer)))))
9917 (org-get-outline-path fast-path-p
9918 level txt)
9919 (list txt))
9920 "/")))
9921 (push (list txt f re (org-refile-marker (point)))
9922 tgs)))
9923 (when (= (point) pos0)
9924 ;; verification function has not moved point
9925 (goto-char (point-at-eol))))))))
9926 (when org-refile-use-cache
9927 (org-refile-cache-put tgs (buffer-file-name) descre))
9928 (setq targets (append tgs targets))
9929 ))))
9419 (message "Getting targets...done") 9930 (message "Getting targets...done")
9420 (nreverse targets))) 9931 (nreverse targets)))
9421 9932
9422 (defun org-protect-slash (s) 9933 (defun org-protect-slash (s)
9423 (while (string-match "/" s) 9934 (while (string-match "/" s)
9426 9937
9427 (defvar org-olpa (make-vector 20 nil)) 9938 (defvar org-olpa (make-vector 20 nil))
9428 9939
9429 (defun org-get-outline-path (&optional fastp level heading) 9940 (defun org-get-outline-path (&optional fastp level heading)
9430 "Return the outline path to the current entry, as a list. 9941 "Return the outline path to the current entry, as a list.
9431 The parameters FASTP, LEVEL, and HEADING are for use be a scanner 9942
9943 The parameters FASTP, LEVEL, and HEADING are for use by a scanner
9432 routine which makes outline path derivations for an entire file, 9944 routine which makes outline path derivations for an entire file,
9433 avoiding backtracing." 9945 avoiding backtracing. Refile target collection makes use of that."
9434 (if fastp 9946 (if fastp
9435 (progn 9947 (progn
9436 (if (> level 19) 9948 (if (> level 19)
9437 (error "Outline path failure, more than 19 levels.")) 9949 (error "Outline path failure, more than 19 levels"))
9438 (loop for i from level upto 19 do 9950 (loop for i from level upto 19 do
9439 (aset org-olpa i nil)) 9951 (aset org-olpa i nil))
9440 (prog1 9952 (prog1
9441 (delq nil (append org-olpa nil)) 9953 (delq nil (append org-olpa nil))
9442 (aset org-olpa level heading))) 9954 (aset org-olpa level heading)))
9448 (when (looking-at org-complex-heading-regexp) 9960 (when (looking-at org-complex-heading-regexp)
9449 (push (org-match-string-no-properties 4) rtn))) 9961 (push (org-match-string-no-properties 4) rtn)))
9450 rtn))))) 9962 rtn)))))
9451 9963
9452 (defun org-format-outline-path (path &optional width prefix) 9964 (defun org-format-outline-path (path &optional width prefix)
9453 "Format the outlie path PATH for display. 9965 "Format the outline path PATH for display.
9454 Width is the maximum number of characters that is available. 9966 Width is the maximum number of characters that is available.
9455 Prefix is a prefix to be included in the returned string, 9967 Prefix is a prefix to be included in the returned string,
9456 such as the file name." 9968 such as the file name."
9457 (setq width (or width 79)) 9969 (setq width (or width 79))
9458 (if prefix (setq width (- width (length prefix)))) 9970 (if prefix (setq width (- width (length prefix))))
9510 (defvar org-after-refile-insert-hook nil 10022 (defvar org-after-refile-insert-hook nil
9511 "Hook run after `org-refile' has inserted its stuff at the new location. 10023 "Hook run after `org-refile' has inserted its stuff at the new location.
9512 Note that this is still *before* the stuff will be removed from 10024 Note that this is still *before* the stuff will be removed from
9513 the *old* location.") 10025 the *old* location.")
9514 10026
10027 (defvar org-capture-last-stored-marker)
9515 (defun org-refile (&optional goto default-buffer rfloc) 10028 (defun org-refile (&optional goto default-buffer rfloc)
9516 "Move the entry at point to another heading. 10029 "Move the entry at point to another heading.
9517 The list of target headings is compiled using the information in 10030 The list of target headings is compiled using the information in
9518 `org-refile-targets', which see. This list is created before each use 10031 `org-refile-targets', which see. This list is created before each use
9519 and will therefore always be up-to-date. 10032 and will therefore always be up-to-date.
9521 At the target location, the entry is filed as a subitem of the target heading. 10034 At the target location, the entry is filed as a subitem of the target heading.
9522 Depending on `org-reverse-note-order', the new subitem will either be the 10035 Depending on `org-reverse-note-order', the new subitem will either be the
9523 first or the last subitem. 10036 first or the last subitem.
9524 10037
9525 If there is an active region, all entries in that region will be moved. 10038 If there is an active region, all entries in that region will be moved.
9526 However, the region must fulfil the requirement that the first heading 10039 However, the region must fulfill the requirement that the first heading
9527 is the first one sets the top-level of the moved text - at most siblings 10040 is the first one sets the top-level of the moved text - at most siblings
9528 below it are allowed. 10041 below it are allowed.
9529 10042
9530 With prefix arg GOTO, the command will only visit the target location, 10043 With prefix arg GOTO, the command will only visit the target location,
9531 not actually move anything. 10044 not actually move anything.
9532 With a double prefix `C-u C-u', go to the location where the last refiling 10045 With a double prefix arg \\[universal-argument] \\[universal-argument], \
10046 go to the location where the last refiling
9533 operation has put the subtree. 10047 operation has put the subtree.
9534 With a prefix argument of `2', refile to the running clock. 10048 With a prefix argument of `2', refile to the running clock.
9535 10049
9536 RFLOC can be a refile location obtained in a different way. 10050 RFLOC can be a refile location obtained in a different way.
9537 10051
9538 See also `org-refile-use-outline-path' and `org-completion-use-ido'" 10052 See also `org-refile-use-outline-path' and `org-completion-use-ido'.
10053
10054 If you are using target caching (see `org-refile-use-cache'),
10055 You have to clear the target cache in order to find new targets.
10056 This can be done with a 0 prefix: `C-0 C-c C-w'"
9539 (interactive "P") 10057 (interactive "P")
9540 (let* ((cbuf (current-buffer)) 10058 (if (member goto '(0 (64)))
9541 (regionp (org-region-active-p)) 10059 (org-refile-cache-clear)
9542 (region-start (and regionp (region-beginning))) 10060 (let* ((cbuf (current-buffer))
9543 (region-end (and regionp (region-end))) 10061 (regionp (org-region-active-p))
9544 (region-length (and regionp (- region-end region-start))) 10062 (region-start (and regionp (region-beginning)))
9545 (filename (buffer-file-name (buffer-base-buffer cbuf))) 10063 (region-end (and regionp (region-end)))
9546 pos it nbuf file re level reversed) 10064 (region-length (and regionp (- region-end region-start)))
9547 (setq last-command nil) 10065 (filename (buffer-file-name (buffer-base-buffer cbuf)))
9548 (when regionp 10066 pos it nbuf file re level reversed)
9549 (goto-char region-start) 10067 (setq last-command nil)
9550 (or (bolp) (goto-char (point-at-bol))) 10068 (when regionp
9551 (setq region-start (point)) 10069 (goto-char region-start)
9552 (unless (org-kill-is-subtree-p 10070 (or (bolp) (goto-char (point-at-bol)))
9553 (buffer-substring region-start region-end)) 10071 (setq region-start (point))
9554 (error "The region is not a (sequence of) subtree(s)"))) 10072 (unless (org-kill-is-subtree-p
9555 (if (equal goto '(16)) 10073 (buffer-substring region-start region-end))
9556 (org-refile-goto-last-stored) 10074 (error "The region is not a (sequence of) subtree(s)")))
9557 (when (or 10075 (if (equal goto '(16))
9558 (and (equal goto 2) 10076 (org-refile-goto-last-stored)
9559 org-clock-hd-marker (marker-buffer org-clock-hd-marker) 10077 (when (or
9560 (prog1 10078 (and (equal goto 2)
9561 (setq it (list (or org-clock-heading "running clock") 10079 org-clock-hd-marker (marker-buffer org-clock-hd-marker)
9562 (buffer-file-name 10080 (prog1
9563 (marker-buffer org-clock-hd-marker)) 10081 (setq it (list (or org-clock-heading "running clock")
9564 "" 10082 (buffer-file-name
9565 (marker-position org-clock-hd-marker))) 10083 (marker-buffer org-clock-hd-marker))
9566 (setq goto nil))) 10084 ""
9567 (setq it (or rfloc 10085 (marker-position org-clock-hd-marker)))
9568 (save-excursion 10086 (setq goto nil)))
9569 (org-refile-get-location 10087 (setq it (or rfloc
9570 (if goto "Goto: " "Refile to: ") default-buffer 10088 (save-excursion
9571 org-refile-allow-creating-parent-nodes))))) 10089 (org-refile-get-location
9572 (setq file (nth 1 it) 10090 (if goto "Goto: " "Refile to: ") default-buffer
9573 re (nth 2 it) 10091 org-refile-allow-creating-parent-nodes)))))
9574 pos (nth 3 it)) 10092 (setq file (nth 1 it)
9575 (if (and (not goto) 10093 re (nth 2 it)
9576 pos 10094 pos (nth 3 it))
9577 (equal (buffer-file-name) file) 10095 (if (and (not goto)
9578 (if regionp 10096 pos
9579 (and (>= pos region-start) 10097 (equal (buffer-file-name) file)
9580 (<= pos region-end)) 10098 (if regionp
9581 (and (>= pos (point)) 10099 (and (>= pos region-start)
9582 (< pos (save-excursion 10100 (<= pos region-end))
9583 (org-end-of-subtree t t)))))) 10101 (and (>= pos (point))
9584 (error "Cannot refile to position inside the tree or region")) 10102 (< pos (save-excursion
9585 10103 (org-end-of-subtree t t))))))
9586 (setq nbuf (or (find-buffer-visiting file) 10104 (error "Cannot refile to position inside the tree or region"))
9587 (find-file-noselect file))) 10105
9588 (if goto 10106 (setq nbuf (or (find-buffer-visiting file)
9589 (progn 10107 (find-file-noselect file)))
9590 (switch-to-buffer nbuf) 10108 (if goto
9591 (goto-char pos)
9592 (org-show-context 'org-goto))
9593 (if regionp
9594 (progn 10109 (progn
9595 (org-kill-new (buffer-substring region-start region-end)) 10110 (switch-to-buffer nbuf)
9596 (org-save-markers-in-region region-start region-end)) 10111 (goto-char pos)
9597 (org-copy-subtree 1 nil t)) 10112 (org-show-context 'org-goto))
9598 (with-current-buffer (setq nbuf (or (find-buffer-visiting file) 10113 (if regionp
9599 (find-file-noselect file))) 10114 (progn
9600 (setq reversed (org-notes-order-reversed-p)) 10115 (org-kill-new (buffer-substring region-start region-end))
9601 (save-excursion 10116 (org-save-markers-in-region region-start region-end))
9602 (save-restriction 10117 (org-copy-subtree 1 nil t))
9603 (widen) 10118 (with-current-buffer (setq nbuf (or (find-buffer-visiting file)
9604 (if pos 10119 (find-file-noselect file)))
9605 (progn 10120 (setq reversed (org-notes-order-reversed-p))
9606 (goto-char pos) 10121 (save-excursion
9607 (looking-at outline-regexp) 10122 (save-restriction
9608 (setq level (org-get-valid-level (funcall outline-level) 1)) 10123 (widen)
9609 (goto-char 10124 (if pos
9610 (if reversed 10125 (progn
9611 (or (outline-next-heading) (point-max)) 10126 (goto-char pos)
9612 (or (save-excursion (org-get-next-sibling)) 10127 (looking-at outline-regexp)
9613 (org-end-of-subtree t t) 10128 (setq level (org-get-valid-level (funcall outline-level) 1))
9614 (point-max))))) 10129 (goto-char
9615 (setq level 1) 10130 (if reversed
9616 (if (not reversed) 10131 (or (outline-next-heading) (point-max))
9617 (goto-char (point-max)) 10132 (or (save-excursion (org-get-next-sibling))
9618 (goto-char (point-min)) 10133 (org-end-of-subtree t t)
9619 (or (outline-next-heading) (goto-char (point-max))))) 10134 (point-max)))))
9620 (if (not (bolp)) (newline)) 10135 (setq level 1)
9621 (org-paste-subtree level) 10136 (if (not reversed)
9622 (when org-log-refile 10137 (goto-char (point-max))
9623 (org-add-log-setup 'refile nil nil 'findpos 10138 (goto-char (point-min))
9624 org-log-refile) 10139 (or (outline-next-heading) (goto-char (point-max)))))
9625 (unless (eq org-log-refile 'note) 10140 (if (not (bolp)) (newline))
9626 (save-excursion (org-add-log-note)))) 10141 (org-paste-subtree level)
9627 (and org-auto-align-tags (org-set-tags nil t)) 10142 (when org-log-refile
9628 (bookmark-set "org-refile-last-stored") 10143 (org-add-log-setup 'refile nil nil 'findpos
9629 (if (fboundp 'deactivate-mark) (deactivate-mark)) 10144 org-log-refile)
9630 (run-hooks 'org-after-refile-insert-hook)))) 10145 (unless (eq org-log-refile 'note)
9631 (if regionp 10146 (save-excursion (org-add-log-note))))
9632 (delete-region (point) (+ (point) region-length)) 10147 (and org-auto-align-tags (org-set-tags nil t))
9633 (org-cut-subtree)) 10148 (bookmark-set "org-refile-last-stored")
9634 (when (featurep 'org-inlinetask) 10149 ;; If we are refiling for capture, make sure that the
9635 (org-inlinetask-remove-END-maybe)) 10150 ;; last-capture pointers point here
9636 (setq org-markers-to-move nil) 10151 (when (org-bound-and-true-p org-refile-for-capture)
9637 (message "Refiled to \"%s\"" (car it)))))) 10152 (bookmark-set "org-capture-last-stored-marker")
9638 (org-reveal)) 10153 (move-marker org-capture-last-stored-marker (point)))
10154 (if (fboundp 'deactivate-mark) (deactivate-mark))
10155 (run-hooks 'org-after-refile-insert-hook))))
10156 (if regionp
10157 (delete-region (point) (+ (point) region-length))
10158 (org-cut-subtree))
10159 (when (featurep 'org-inlinetask)
10160 (org-inlinetask-remove-END-maybe))
10161 (setq org-markers-to-move nil)
10162 (message "Refiled to \"%s\" in file %s" (car it) file)))))))
9639 10163
9640 (defun org-refile-goto-last-stored () 10164 (defun org-refile-goto-last-stored ()
9641 "Go to the location where the last refile was stored." 10165 "Go to the location where the last refile was stored."
9642 (interactive) 10166 (interactive)
9643 (bookmark-jump "org-refile-last-stored") 10167 (bookmark-jump "org-refile-last-stored")
9846 (or (looking-at org-dblock-start-re) 10370 (or (looking-at org-dblock-start-re)
9847 (org-beginning-of-dblock)) 10371 (org-beginning-of-dblock))
9848 (org-update-dblock))) 10372 (org-update-dblock)))
9849 10373
9850 (defun org-update-dblock () 10374 (defun org-update-dblock ()
9851 "Update the dynamic block at point 10375 "Update the dynamic block at point.
9852 This means to empty the block, parse for parameters and then call 10376 This means to empty the block, parse for parameters and then call
9853 the correct writing function." 10377 the correct writing function."
9854 (save-window-excursion 10378 (save-window-excursion
9855 (let* ((pos (point)) 10379 (let* ((pos (point))
9856 (line (org-current-line)) 10380 (line (org-current-line))
9941 ("i" "#+include %file ?" 10465 ("i" "#+include %file ?"
9942 "<include file=%file markup=\"?\">") 10466 "<include file=%file markup=\"?\">")
9943 ) 10467 )
9944 "Structure completion elements. 10468 "Structure completion elements.
9945 This is a list of abbreviation keys and values. The value gets inserted 10469 This is a list of abbreviation keys and values. The value gets inserted
9946 it you type @samp{.} followed by the key and then the completion key, 10470 if you type `<' followed by the key and then press the completion key,
9947 usually `M-TAB'. %file will be replaced by a file name after prompting 10471 usually `M-TAB'. %file will be replaced by a file name after prompting
9948 for the file using completion. 10472 for the file using completion.
9949 There are two templates for each key, the first uses the original Org syntax, 10473 There are two templates for each key, the first uses the original Org syntax,
9950 the second uses Emacs Muse-like syntax tags. These Muse-like tags become 10474 the second uses Emacs Muse-like syntax tags. These Muse-like tags become
9951 the default when the /org-mtags.el/ module has been loaded. See also the 10475 the default when the /org-mtags.el/ module has been loaded. See also the
9952 variable `org-mtags-prefer-muse-templates'. 10476 variable `org-mtags-prefer-muse-templates'.
9953 This is an experimental feature, it is undecided if it is going to stay in." 10477 This is an experimental feature, it is undecided if it is going to stay in."
9954 :group 'org-completion 10478 :group 'org-completion
9955 :type '(repeat 10479 :type '(repeat
9956 (string :tag "Key") 10480 (string :tag "Key")
10166 (push (nth 2 e) rtn))) 10690 (push (nth 2 e) rtn)))
10167 rtn))))) 10691 rtn)))))
10168 10692
10169 (defvar org-todo-setup-filter-hook nil 10693 (defvar org-todo-setup-filter-hook nil
10170 "Hook for functions that pre-filter todo specs. 10694 "Hook for functions that pre-filter todo specs.
10171 10695 Each function takes a todo spec and returns either nil or the spec
10172 Each function takes a todo spec and returns either `nil' or the spec
10173 transformed into canonical form." ) 10696 transformed into canonical form." )
10174 10697
10175 (defvar org-todo-get-default-hook nil 10698 (defvar org-todo-get-default-hook nil
10176 "Hook for functions that get a default item for todo. 10699 "Hook for functions that get a default item for todo.
10177
10178 Each function takes arguments (NEW-MARK OLD-MARK) and returns either 10700 Each function takes arguments (NEW-MARK OLD-MARK) and returns either
10179 `nil' or a string to be used for the todo mark." ) 10701 nil or a string to be used for the todo mark." )
10180 10702
10181 (defvar org-agenda-headline-snapshot-before-repeat) 10703 (defvar org-agenda-headline-snapshot-before-repeat)
10182 10704
10183 (defun org-todo (&optional arg) 10705 (defun org-todo (&optional arg)
10184 "Change the TODO state of an item. 10706 "Change the TODO state of an item.
10191 By default the available states are \"TODO\" and \"DONE\". 10713 By default the available states are \"TODO\" and \"DONE\".
10192 So for this example: when the item starts with TODO, it is changed to DONE. 10714 So for this example: when the item starts with TODO, it is changed to DONE.
10193 When it starts with DONE, the DONE is removed. And when neither TODO nor 10715 When it starts with DONE, the DONE is removed. And when neither TODO nor
10194 DONE are present, add TODO at the beginning of the heading. 10716 DONE are present, add TODO at the beginning of the heading.
10195 10717
10196 With C-u prefix arg, use completion to determine the new state. 10718 With \\[universal-argument] prefix arg, use completion to determine the new \
10719 state.
10197 With numeric prefix arg, switch to that state. 10720 With numeric prefix arg, switch to that state.
10198 With a double C-u prefix, switch to the next set of TODO keywords (nextset). 10721 With a double \\[universal-argument] prefix, switch to the next set of TODO \
10199 With a triple C-u prefix, circumvent any state blocking. 10722 keywords (nextset).
10723 With a triple \\[universal-argument] prefix, circumvent any state blocking.
10200 10724
10201 For calling through lisp, arg is also interpreted in the following way: 10725 For calling through lisp, arg is also interpreted in the following way:
10202 'none -> empty state 10726 'none -> empty state
10203 \"\"(empty string) -> switch to empty state 10727 \"\"(empty string) -> switch to empty state
10204 'done -> switch to DONE 10728 'done -> switch to DONE
10222 (if (looking-at outline-regexp) (goto-char (1- (match-end 0)))) 10746 (if (looking-at outline-regexp) (goto-char (1- (match-end 0))))
10223 (or (looking-at (concat " +" org-todo-regexp "\\( +\\|$\\)")) 10747 (or (looking-at (concat " +" org-todo-regexp "\\( +\\|$\\)"))
10224 (looking-at " *")) 10748 (looking-at " *"))
10225 (let* ((match-data (match-data)) 10749 (let* ((match-data (match-data))
10226 (startpos (point-at-bol)) 10750 (startpos (point-at-bol))
10227 (logging (save-match-data (org-entry-get nil "LOGGING" t))) 10751 (logging (save-match-data (org-entry-get nil "LOGGING" t t)))
10228 (org-log-done org-log-done) 10752 (org-log-done org-log-done)
10229 (org-log-repeat org-log-repeat) 10753 (org-log-repeat org-log-repeat)
10230 (org-todo-log-states org-todo-log-states) 10754 (org-todo-log-states org-todo-log-states)
10231 (this (match-string 1)) 10755 (this (match-string 1))
10232 (hl-pos (match-beginning 0)) 10756 (hl-pos (match-beginning 0))
10438 (save-excursion 10962 (save-excursion
10439 (org-back-to-heading t) 10963 (org-back-to-heading t)
10440 (let* ((pos (point)) 10964 (let* ((pos (point))
10441 (parent-pos (and (org-up-heading-safe) (point)))) 10965 (parent-pos (and (org-up-heading-safe) (point))))
10442 (if (not parent-pos) (throw 'dont-block t)) ; no parent 10966 (if (not parent-pos) (throw 'dont-block t)) ; no parent
10443 (when (and (org-entry-get (point) "ORDERED") 10967 (when (and (org-not-nil (org-entry-get (point) "ORDERED"))
10444 (forward-line 1) 10968 (forward-line 1)
10445 (re-search-forward org-not-done-heading-regexp pos t)) 10969 (re-search-forward org-not-done-heading-regexp pos t))
10446 (throw 'dont-block nil)) ; block, there is an older sibling not done. 10970 (throw 'dont-block nil)) ; block, there is an older sibling not done.
10447 ;; Search further up the hierarchy, to see if an anchestor is blocked 10971 ;; Search further up the hierarchy, to see if an anchestor is blocked
10448 (while t 10972 (while t
10450 (if (not (looking-at org-not-done-heading-regexp)) 10974 (if (not (looking-at org-not-done-heading-regexp))
10451 (throw 'dont-block t)) ; do not block, parent is not a TODO 10975 (throw 'dont-block t)) ; do not block, parent is not a TODO
10452 (setq pos (point)) 10976 (setq pos (point))
10453 (setq parent-pos (and (org-up-heading-safe) (point))) 10977 (setq parent-pos (and (org-up-heading-safe) (point)))
10454 (if (not parent-pos) (throw 'dont-block t)) ; no parent 10978 (if (not parent-pos) (throw 'dont-block t)) ; no parent
10455 (when (and (org-entry-get (point) "ORDERED") 10979 (when (and (org-not-nil (org-entry-get (point) "ORDERED"))
10456 (forward-line 1) 10980 (forward-line 1)
10457 (re-search-forward org-not-done-heading-regexp pos t)) 10981 (re-search-forward org-not-done-heading-regexp pos t))
10458 (throw 'dont-block nil)))))))) ; block, older sibling not done. 10982 (throw 'dont-block nil)))))))) ; block, older sibling not done.
10459 10983
10460 (defcustom org-track-ordered-property-with-tag nil 10984 (defcustom org-track-ordered-property-with-tag nil
10844 (whata '(("d" . day) ("m" . month) ("y" . year))) 11368 (whata '(("d" . day) ("m" . month) ("y" . year)))
10845 (msg "Entry repeats: ") 11369 (msg "Entry repeats: ")
10846 (org-log-done nil) 11370 (org-log-done nil)
10847 (org-todo-log-states nil) 11371 (org-todo-log-states nil)
10848 (nshiftmax 10) (nshift 0) 11372 (nshiftmax 10) (nshift 0)
10849 re type n what ts time) 11373 re type n what ts time to-state)
10850 (when repeat 11374 (when repeat
10851 (if (eq org-log-repeat t) (setq org-log-repeat 'state)) 11375 (if (eq org-log-repeat t) (setq org-log-repeat 'state))
10852 (org-todo (if (eq interpret 'type) last-state head)) 11376 (setq to-state (or (org-entry-get nil "REPEAT_TO_STATE")
10853 (org-entry-put nil "LAST_REPEAT" (format-time-string 11377 org-todo-repeat-to-state))
10854 (org-time-stamp-format t t))) 11378 (unless (and to-state (member to-state org-todo-keywords-1))
11379 (setq to-state (if (eq interpret 'type) last-state head)))
11380 (org-todo to-state)
11381 (when (or org-log-repeat (org-entry-get nil "CLOCK"))
11382 (org-entry-put nil "LAST_REPEAT" (format-time-string
11383 (org-time-stamp-format t t))))
10855 (when org-log-repeat 11384 (when org-log-repeat
10856 (if (or (memq 'org-add-log-note (default-value 'post-command-hook)) 11385 (if (or (memq 'org-add-log-note (default-value 'post-command-hook))
10857 (memq 'org-add-log-note post-command-hook)) 11386 (memq 'org-add-log-note post-command-hook))
10858 ;; OK, we are already setup for some record 11387 ;; OK, we are already setup for some record
10859 (if (eq org-log-repeat 'note) 11388 (if (eq org-log-repeat 'note)
11013 (let ((time (org-entry-get pom "SCHEDULED" inherit))) 11542 (let ((time (org-entry-get pom "SCHEDULED" inherit)))
11014 (when time 11543 (when time
11015 (apply 'encode-time (org-parse-time-string time))))) 11544 (apply 'encode-time (org-parse-time-string time)))))
11016 11545
11017 (defun org-get-deadline-time (pom &optional inherit) 11546 (defun org-get-deadline-time (pom &optional inherit)
11018 "Get the deadine as a time tuple, of a format suitable for 11547 "Get the deadline as a time tuple, of a format suitable for
11019 calling org-deadline with, or if there is no scheduling, returns 11548 calling org-deadline with, or if there is no scheduling, returns
11020 nil." 11549 nil."
11021 (let ((time (org-entry-get pom "DEADLINE" inherit))) 11550 (let ((time (org-entry-get pom "DEADLINE" inherit)))
11022 (when time 11551 (when time
11023 (apply 'encode-time (org-parse-time-string time))))) 11552 (apply 'encode-time (org-parse-time-string time)))))
11131 (eq what 'closed) 11660 (eq what 'closed)
11132 nil nil (list org-end-time-was-given))) 11661 nil nil (list org-end-time-was-given)))
11133 (end-of-line 1)) 11662 (end-of-line 1))
11134 (goto-char (point-min)) 11663 (goto-char (point-min))
11135 (widen) 11664 (widen)
11136 (if (and (looking-at "[ \t]+\n") 11665 (if (and (looking-at "[ \t]*\n")
11137 (equal (char-before) ?\n)) 11666 (equal (char-before) ?\n))
11138 (delete-region (1- (point)) (point-at-eol))) 11667 (delete-region (1- (point)) (point-at-eol)))
11139 ts)))))) 11668 ts))))))
11140 11669
11141 (defvar org-log-note-marker (make-marker)) 11670 (defvar org-log-note-marker (make-marker))
11281 (list (cons "%u" (user-login-name)) 11810 (list (cons "%u" (user-login-name))
11282 (cons "%U" user-full-name) 11811 (cons "%U" user-full-name)
11283 (cons "%t" (format-time-string 11812 (cons "%t" (format-time-string
11284 (org-time-stamp-format 'long 'inactive) 11813 (org-time-stamp-format 'long 'inactive)
11285 (current-time))) 11814 (current-time)))
11815 (cons "%T" (format-time-string
11816 (org-time-stamp-format 'long nil)
11817 (current-time)))
11286 (cons "%s" (if org-log-note-state 11818 (cons "%s" (if org-log-note-state
11287 (concat "\"" org-log-note-state "\"") 11819 (concat "\"" org-log-note-state "\"")
11288 "")) 11820 ""))
11289 (cons "%S" (if org-log-note-previous-state 11821 (cons "%S" (if org-log-note-previous-state
11290 (concat "\"" org-log-note-previous-state "\"") 11822 (concat "\"" org-log-note-previous-state "\"")
11335 (defun org-sparse-tree (&optional arg) 11867 (defun org-sparse-tree (&optional arg)
11336 "Create a sparse tree, prompt for the details. 11868 "Create a sparse tree, prompt for the details.
11337 This command can create sparse trees. You first need to select the type 11869 This command can create sparse trees. You first need to select the type
11338 of match used to create the tree: 11870 of match used to create the tree:
11339 11871
11340 t Show entries with a specific TODO keyword. 11872 t Show all TODO entries.
11873 T Show entries with a specific TODO keyword.
11341 m Show entries selected by a tags/property match. 11874 m Show entries selected by a tags/property match.
11342 p Enter a property name and its value (both with completion on existing 11875 p Enter a property name and its value (both with completion on existing
11343 names/values) and show entries with that property. 11876 names/values) and show entries with that property.
11344 / Show entries matching a regular expression (`r' can be used as well) 11877 / Show entries matching a regular expression (`r' can be used as well)
11345 d Show deadlines due within `org-deadline-warning-days'. 11878 d Show deadlines due within `org-deadline-warning-days'.
11346 b Show deadlines and scheduled items before a date. 11879 b Show deadlines and scheduled items before a date.
11347 a Show deadlines and scheduled items after a date." 11880 a Show deadlines and scheduled items after a date."
11348 (interactive "P") 11881 (interactive "P")
11349 (let (ans kwd value) 11882 (let (ans kwd value)
11350 (message "Sparse tree: [/]regexp [t]odo-kwd [m]atch [p]roperty [d]eadlines [b]efore-date [a]fter-date") 11883 (message "Sparse tree: [/]regexp [t]odo [T]odo-kwd [m]atch [p]roperty [d]eadlines\n [b]efore-date [a]fter-date")
11351 (setq ans (read-char-exclusive)) 11884 (setq ans (read-char-exclusive))
11352 (cond 11885 (cond
11353 ((equal ans ?d) 11886 ((equal ans ?d)
11354 (call-interactively 'org-check-deadlines)) 11887 (call-interactively 'org-check-deadlines))
11355 ((equal ans ?b) 11888 ((equal ans ?b)
11356 (call-interactively 'org-check-before-date)) 11889 (call-interactively 'org-check-before-date))
11357 ((equal ans ?a) 11890 ((equal ans ?a)
11358 (call-interactively 'org-check-after-date)) 11891 (call-interactively 'org-check-after-date))
11359 ((equal ans ?t) 11892 ((equal ans ?t)
11893 (org-show-todo-tree nil))
11894 ((equal ans ?T)
11360 (org-show-todo-tree '(4))) 11895 (org-show-todo-tree '(4)))
11361 ((member ans '(?T ?m)) 11896 ((member ans '(?T ?m))
11362 (call-interactively 'org-match-sparse-tree)) 11897 (call-interactively 'org-match-sparse-tree))
11363 ((member ans '(?p ?P)) 11898 ((member ans '(?p ?P))
11364 (setq kwd (org-icompleting-read "Property: " 11899 (setq kwd (org-icompleting-read "Property: "
11426 (if (interactive-p) 11961 (if (interactive-p)
11427 (message "%d match(es) for regexp %s" cnt regexp)) 11962 (message "%d match(es) for regexp %s" cnt regexp))
11428 cnt)) 11963 cnt))
11429 11964
11430 (defun org-show-context (&optional key) 11965 (defun org-show-context (&optional key)
11431 "Make sure point and context and visible. 11966 "Make sure point and context are visible.
11432 How much context is shown depends upon the variables 11967 How much context is shown depends upon the variables
11433 `org-show-hierarchy-above', `org-show-following-heading'. and 11968 `org-show-hierarchy-above', `org-show-following-heading'. and
11434 `org-show-siblings'." 11969 `org-show-siblings'."
11435 (let ((heading-p (org-on-heading-p t)) 11970 (let ((heading-p (org-on-heading-p t))
11436 (hierarchy-p (org-get-alist-option org-show-hierarchy-above key)) 11971 (hierarchy-p (org-get-alist-option org-show-hierarchy-above key))
11469 not t for the search context. 12004 not t for the search context.
11470 12005
11471 With optional argument SIBLINGS, on each level of the hierarchy all 12006 With optional argument SIBLINGS, on each level of the hierarchy all
11472 siblings are shown. This repairs the tree structure to what it would 12007 siblings are shown. This repairs the tree structure to what it would
11473 look like when opened with hierarchical calls to `org-cycle'. 12008 look like when opened with hierarchical calls to `org-cycle'.
11474 With double optional argument `C-u C-u', go to the parent and show the 12009 With double optional argument \\[universal-argument] \\[universal-argument], \
12010 go to the parent and show the
11475 entire tree." 12011 entire tree."
11476 (interactive "P") 12012 (interactive "P")
11477 (run-hooks 'org-reveal-start-hook) 12013 (run-hooks 'org-reveal-start-hook)
11478 (let ((org-show-hierarchy-above t) 12014 (let ((org-show-hierarchy-above t)
11479 (org-show-following-heading t) 12015 (org-show-following-heading t)
11485 (org-show-subtree) 12021 (org-show-subtree)
11486 (run-hook-with-args 'org-cycle-hook 'subtree))))) 12022 (run-hook-with-args 'org-cycle-hook 'subtree)))))
11487 12023
11488 (defun org-highlight-new-match (beg end) 12024 (defun org-highlight-new-match (beg end)
11489 "Highlight from BEG to END and mark the highlight is an occur headline." 12025 "Highlight from BEG to END and mark the highlight is an occur headline."
11490 (let ((ov (org-make-overlay beg end))) 12026 (let ((ov (make-overlay beg end)))
11491 (org-overlay-put ov 'face 'secondary-selection) 12027 (overlay-put ov 'face 'secondary-selection)
11492 (push ov org-occur-highlights))) 12028 (push ov org-occur-highlights)))
11493 12029
11494 (defun org-remove-occur-highlights (&optional beg end noremove) 12030 (defun org-remove-occur-highlights (&optional beg end noremove)
11495 "Remove the occur highlights from the buffer. 12031 "Remove the occur highlights from the buffer.
11496 BEG and END are ignored. If NOREMOVE is nil, remove this function 12032 BEG and END are ignored. If NOREMOVE is nil, remove this function
11497 from the `before-change-functions' in the current buffer." 12033 from the `before-change-functions' in the current buffer."
11498 (interactive) 12034 (interactive)
11499 (unless org-inhibit-highlight-removal 12035 (unless org-inhibit-highlight-removal
11500 (mapc 'org-delete-overlay org-occur-highlights) 12036 (mapc 'delete-overlay org-occur-highlights)
11501 (setq org-occur-highlights nil) 12037 (setq org-occur-highlights nil)
11502 (setq org-occur-parameters nil) 12038 (setq org-occur-parameters nil)
11503 (unless noremove 12039 (unless noremove
11504 (remove-hook 'before-change-functions 12040 (remove-hook 'before-change-functions
11505 'org-remove-occur-highlights 'local)))) 12041 'org-remove-occur-highlights 'local))))
11998 "Does re match any element of list?" 12534 "Does re match any element of list?"
11999 (setq list (mapcar (lambda (x) (string-match re x)) list)) 12535 (setq list (mapcar (lambda (x) (string-match re x)) list))
12000 (delq nil list)) 12536 (delq nil list))
12001 12537
12002 (defvar org-add-colon-after-tag-completion nil) ;; dynamically scoped param 12538 (defvar org-add-colon-after-tag-completion nil) ;; dynamically scoped param
12003 (defvar org-tags-overlay (org-make-overlay 1 1)) 12539 (defvar org-tags-overlay (make-overlay 1 1))
12004 (org-detach-overlay org-tags-overlay) 12540 (org-detach-overlay org-tags-overlay)
12005 12541
12006 (defun org-get-local-tags-at (&optional pos) 12542 (defun org-get-local-tags-at (&optional pos)
12007 "Get a list of tags defined in the current headline." 12543 "Get a list of tags defined in the current headline."
12008 (org-get-tags-at pos 'local)) 12544 (org-get-tags-at pos 'local))
12150 (insert " " data) 12686 (insert " " data)
12151 (org-set-tags nil 'align))) 12687 (org-set-tags nil 'align)))
12152 (beginning-of-line 1) 12688 (beginning-of-line 1)
12153 (if (looking-at ".*?\\([ \t]+\\)$") 12689 (if (looking-at ".*?\\([ \t]+\\)$")
12154 (delete-region (match-beginning 1) (match-end 1)))))) 12690 (delete-region (match-beginning 1) (match-end 1))))))
12691
12692 (defun org-align-all-tags ()
12693 "Align the tags i all headings."
12694 (interactive)
12695 (save-excursion
12696 (or (ignore-errors (org-back-to-heading t))
12697 (outline-next-heading))
12698 (if (org-on-heading-p)
12699 (org-set-tags t)
12700 (message "No headings"))))
12155 12701
12156 (defun org-set-tags (&optional arg just-align) 12702 (defun org-set-tags (&optional arg just-align)
12157 "Set the tags for the current headline. 12703 "Set the tags for the current headline.
12158 With prefix ARG, realign all tags in headings in the current buffer." 12704 With prefix ARG, realign all tags in headings in the current buffer."
12159 (interactive "P") 12705 (interactive "P")
12364 (concat 12910 (concat
12365 (buffer-substring (1- (point)) (point)) 12911 (buffer-substring (1- (point)) (point))
12366 (if (> (current-column) org-tags-column) 12912 (if (> (current-column) org-tags-column)
12367 " " 12913 " "
12368 (make-string (- org-tags-column (current-column)) ?\ )))))) 12914 (make-string (- org-tags-column (current-column)) ?\ ))))))
12369 (org-move-overlay org-tags-overlay ov-start ov-end) 12915 (move-overlay org-tags-overlay ov-start ov-end)
12370 (save-window-excursion 12916 (save-window-excursion
12371 (if expert 12917 (if expert
12372 (set-buffer (get-buffer-create " *Org tags*")) 12918 (set-buffer (get-buffer-create " *Org tags*"))
12373 (delete-other-windows) 12919 (delete-other-windows)
12374 (split-window-vertically) 12920 (split-window-vertically)
12672 (defconst org-default-properties 13218 (defconst org-default-properties
12673 '("ARCHIVE" "CATEGORY" "SUMMARY" "DESCRIPTION" "CUSTOM_ID" 13219 '("ARCHIVE" "CATEGORY" "SUMMARY" "DESCRIPTION" "CUSTOM_ID"
12674 "LOCATION" "LOGGING" "COLUMNS" "VISIBILITY" 13220 "LOCATION" "LOGGING" "COLUMNS" "VISIBILITY"
12675 "TABLE_EXPORT_FORMAT" "TABLE_EXPORT_FILE" 13221 "TABLE_EXPORT_FORMAT" "TABLE_EXPORT_FILE"
12676 "EXPORT_FILE_NAME" "EXPORT_TITLE" "EXPORT_AUTHOR" "EXPORT_DATE" 13222 "EXPORT_FILE_NAME" "EXPORT_TITLE" "EXPORT_AUTHOR" "EXPORT_DATE"
12677 "ORDERED" "NOBLOCKING" "COOKIE_DATA" "LOG_INTO_DRAWER" 13223 "ORDERED" "NOBLOCKING" "COOKIE_DATA" "LOG_INTO_DRAWER" "REPEAT_TO_STATE"
12678 "CLOCK_MODELINE_TOTAL" "STYLE" "HTML_CONTAINER_CLASS") 13224 "CLOCK_MODELINE_TOTAL" "STYLE" "HTML_CONTAINER_CLASS")
12679 "Some properties that are used by Org-mode for various purposes. 13225 "Some properties that are used by Org-mode for various purposes.
12680 Being in this list makes sure that they are offered for completion.") 13226 Being in this list makes sure that they are offered for completion.")
12681 13227
12682 (defconst org-property-start-re "^[ \t]*:PROPERTIES:[ \t]*$" 13228 (defconst org-property-start-re "^[ \t]*:PROPERTIES:[ \t]*$"
12762 (defun org-at-property-p () 13308 (defun org-at-property-p ()
12763 "Is cursor inside a property drawer?" 13309 "Is cursor inside a property drawer?"
12764 (save-excursion 13310 (save-excursion
12765 (beginning-of-line 1) 13311 (beginning-of-line 1)
12766 (when (looking-at (org-re "^[ \t]*\\(:\\([[:alpha:]][[:alnum:]_-]*\\):\\)[ \t]*\\(.*\\)")) 13312 (when (looking-at (org-re "^[ \t]*\\(:\\([[:alpha:]][[:alnum:]_-]*\\):\\)[ \t]*\\(.*\\)"))
12767 (let ((match (match-data)) ;; Keep match-data for use by calling 13313 (save-match-data ;; Used by calling procedures
12768 (p (point)) ;; procedures. 13314 (let ((p (point))
12769 (range (unless (org-before-first-heading-p) 13315 (range (unless (org-before-first-heading-p)
12770 (org-get-property-block)))) 13316 (org-get-property-block))))
12771 (prog1 (and range (<= (car range) p) (< p (cdr range))) 13317 (and range (<= (car range) p) (< p (cdr range))))))))
12772 (set-match-data match))))))
12773 13318
12774 (defun org-get-property-block (&optional beg end force) 13319 (defun org-get-property-block (&optional beg end force)
12775 "Return the (beg . end) range of the body of the property drawer. 13320 "Return the (beg . end) range of the body of the property drawer.
12776 BEG and END can be beginning and end of subtree, if not given 13321 BEG and END can be beginning and end of subtree, if not given
12777 they will be found. 13322 they will be found.
12815 (setq which (or which 'all)) 13360 (setq which (or which 'all))
12816 (org-with-point-at pom 13361 (org-with-point-at pom
12817 (let ((clockstr (substring org-clock-string 0 -1)) 13362 (let ((clockstr (substring org-clock-string 0 -1))
12818 (excluded '("TODO" "TAGS" "ALLTAGS" "PRIORITY" "BLOCKED")) 13363 (excluded '("TODO" "TAGS" "ALLTAGS" "PRIORITY" "BLOCKED"))
12819 (case-fold-search nil) 13364 (case-fold-search nil)
12820 beg end range props sum-props key value string clocksum) 13365 beg end range props sum-props key key1 value string clocksum)
12821 (save-excursion 13366 (save-excursion
12822 (when (condition-case nil 13367 (when (condition-case nil
12823 (and (org-mode-p) (org-back-to-heading t)) 13368 (and (org-mode-p) (org-back-to-heading t))
12824 (error nil)) 13369 (error nil))
12825 (setq beg (point)) 13370 (setq beg (point))
12846 ":")) 13391 ":"))
12847 props)) 13392 props))
12848 (when (or (not specific) (string= specific "BLOCKED")) 13393 (when (or (not specific) (string= specific "BLOCKED"))
12849 (push (cons "BLOCKED" (if (org-entry-blocked-p) "t" "")) props)) 13394 (push (cons "BLOCKED" (if (org-entry-blocked-p) "t" "")) props))
12850 (when (or (not specific) 13395 (when (or (not specific)
12851 (member specific org-all-time-keywords) 13396 (member specific
12852 (member specific '("TIMESTAMP" "TIMESTAMP_IA"))) 13397 '("SCHEDULED" "DEADLINE" "CLOCK" "CLOSED"
13398 "TIMESTAMP" "TIMESTAMP_IA")))
12853 (while (re-search-forward org-maybe-keyword-time-regexp end t) 13399 (while (re-search-forward org-maybe-keyword-time-regexp end t)
12854 (setq key (if (match-end 1) (substring (org-match-string-no-properties 1) 0 -1)) 13400 (setq key (if (match-end 1)
13401 (substring (org-match-string-no-properties 1)
13402 0 -1))
12855 string (if (equal key clockstr) 13403 string (if (equal key clockstr)
12856 (org-no-properties 13404 (org-no-properties
12857 (org-trim 13405 (org-trim
12858 (buffer-substring 13406 (buffer-substring
12859 (match-beginning 3) (goto-char (point-at-eol))))) 13407 (match-beginning 3) (goto-char
12860 (substring (org-match-string-no-properties 3) 1 -1))) 13408 (point-at-eol)))))
12861 (unless key 13409 (substring (org-match-string-no-properties 3)
12862 (if (= (char-after (match-beginning 3)) ?\[) 13410 1 -1)))
12863 (setq key "TIMESTAMP_IA") 13411 ;; Get the correct property name from the key. This is
12864 (setq key "TIMESTAMP"))) 13412 ;; necessary if the user has configured time keywords.
12865 (when (or (equal key clockstr) (not (assoc key props))) 13413 (setq key1 (concat key ":"))
13414 (cond
13415 ((not key)
13416 (setq key
13417 (if (= (char-after (match-beginning 3)) ?\[)
13418 "TIMESTAMP_IA" "TIMESTAMP")))
13419 ((equal key1 org-scheduled-string) (setq key "SCHEDULED"))
13420 ((equal key1 org-deadline-string) (setq key "DEADLINE"))
13421 ((equal key1 org-closed-string) (setq key "CLOSED"))
13422 ((equal key1 org-clock-string) (setq key "CLOCK")))
13423 (when (or (equal key "CLOCK") (not (assoc key props)))
12866 (push (cons key string) props)))) 13424 (push (cons key string) props))))
12867
12868 ) 13425 )
12869 13426
12870 (when (memq which '(all standard)) 13427 (when (memq which '(all standard))
12871 ;; Get the standard properties, like :PROP: ... 13428 ;; Get the standard properties, like :PROP: ...
12872 (setq range (org-get-property-block beg end)) 13429 (setq range (org-get-property-block beg end))
12889 (progn (org-refresh-category-properties) 13446 (progn (org-refresh-category-properties)
12890 (org-get-category)))) 13447 (org-get-category))))
12891 (push (cons "CATEGORY" value) props)) 13448 (push (cons "CATEGORY" value) props))
12892 (append sum-props (nreverse props))))))) 13449 (append sum-props (nreverse props)))))))
12893 13450
12894 (defun org-entry-get (pom property &optional inherit) 13451 (defun org-entry-get (pom property &optional inherit literal-nil)
12895 "Get value of PROPERTY for entry at point-or-marker POM. 13452 "Get value of PROPERTY for entry at point-or-marker POM.
12896 If INHERIT is non-nil and the entry does not have the property, 13453 If INHERIT is non-nil and the entry does not have the property,
12897 then also check higher levels of the hierarchy. 13454 then also check higher levels of the hierarchy.
12898 If INHERIT is the symbol `selective', use inheritance only if the setting 13455 If INHERIT is the symbol `selective', use inheritance only if the setting
12899 in `org-use-property-inheritance' selects PROPERTY for inheritance. 13456 in `org-use-property-inheritance' selects PROPERTY for inheritance.
12900 If the property is present but empty, the return value is the empty string. 13457 If the property is present but empty, the return value is the empty string.
12901 If the property is not present at all, nil is returned." 13458 If the property is not present at all, nil is returned.
13459
13460 If LITERAL-NIL is set, return the string value \"nil\" as a string,
13461 do not interpret it as the list atom nil. This is used for inheritance
13462 when a \"nil\" value can supersede a non-nil value higher up the hierarchy."
12902 (org-with-point-at pom 13463 (org-with-point-at pom
12903 (if (and inherit (if (eq inherit 'selective) 13464 (if (and inherit (if (eq inherit 'selective)
12904 (org-property-inherit-p property) 13465 (org-property-inherit-p property)
12905 t)) 13466 t))
12906 (org-entry-get-with-inheritance property) 13467 (org-entry-get-with-inheritance property literal-nil)
12907 (if (member property org-special-properties) 13468 (if (member property org-special-properties)
12908 ;; We need a special property. Use `org-entry-properties' to 13469 ;; We need a special property. Use `org-entry-properties' to
12909 ;; retrieve it, but specify the wanted property 13470 ;; retrieve it, but specify the wanted property
12910 (cdr (assoc property (org-entry-properties nil 'special property))) 13471 (cdr (assoc property (org-entry-properties nil 'special property)))
12911 (let ((range (org-get-property-block))) 13472 (let ((range (org-get-property-block)))
12914 (re-search-forward 13475 (re-search-forward
12915 (concat "^[ \t]*:" property ":[ \t]*\\(.*[^ \t\r\n\f\v]\\)?") 13476 (concat "^[ \t]*:" property ":[ \t]*\\(.*[^ \t\r\n\f\v]\\)?")
12916 (cdr range) t)) 13477 (cdr range) t))
12917 ;; Found the property, return it. 13478 ;; Found the property, return it.
12918 (if (match-end 1) 13479 (if (match-end 1)
12919 (org-match-string-no-properties 1) 13480 (if literal-nil
13481 (org-match-string-no-properties 1)
13482 (org-not-nil (org-match-string-no-properties 1)))
12920 ""))))))) 13483 "")))))))
12921 13484
12922 (defun org-property-or-variable-value (var &optional inherit) 13485 (defun org-property-or-variable-value (var &optional inherit)
12923 "Check if there is a property fixing the value of VAR. 13486 "Check if there is a property fixing the value of VAR.
12924 If yes, return this value. If not, return the current value of the variable." 13487 If yes, return this value. If not, return the current value of the variable."
13009 location of the entry where the inheritance search matched. If there was 13572 location of the entry where the inheritance search matched. If there was
13010 no match, the marker will point nowhere. 13573 no match, the marker will point nowhere.
13011 Note that also `org-entry-get' calls this function, if the INHERIT flag 13574 Note that also `org-entry-get' calls this function, if the INHERIT flag
13012 is set.") 13575 is set.")
13013 13576
13014 (defun org-entry-get-with-inheritance (property) 13577 (defun org-entry-get-with-inheritance (property &optional literal-nil)
13015 "Get entry property, and search higher levels if not present." 13578 "Get entry property, and search higher levels if not present.
13579 The search will stop at the first ancestor which has the property defined.
13580 If the value found is \"nil\", return nil to show that the property
13581 should be considered as undefined (this is the meaning of nil here).
13582 However, if LITERAL-NIL is set, return the string value \"nil\" instead."
13016 (move-marker org-entry-property-inherited-from nil) 13583 (move-marker org-entry-property-inherited-from nil)
13017 (let (tmp) 13584 (let (tmp)
13018 (save-excursion 13585 (save-excursion
13019 (save-restriction 13586 (save-restriction
13020 (widen) 13587 (widen)
13021 (catch 'ex 13588 (catch 'ex
13022 (while t 13589 (while t
13023 (when (setq tmp (org-entry-get nil property)) 13590 (when (setq tmp (org-entry-get nil property nil 'literal-nil))
13024 (org-back-to-heading t) 13591 (org-back-to-heading t)
13025 (move-marker org-entry-property-inherited-from (point)) 13592 (move-marker org-entry-property-inherited-from (point))
13026 (throw 'ex tmp)) 13593 (throw 'ex tmp))
13027 (or (org-up-heading-safe) (throw 'ex nil))))) 13594 (or (org-up-heading-safe) (throw 'ex nil)))))
13028 (or tmp 13595 (setq tmp (or tmp
13029 (cdr (assoc property org-file-properties)) 13596 (cdr (assoc property org-file-properties))
13030 (cdr (assoc property org-global-properties)) 13597 (cdr (assoc property org-global-properties))
13031 (cdr (assoc property org-global-properties-fixed)))))) 13598 (cdr (assoc property org-global-properties-fixed))))
13599 (if literal-nil tmp (org-not-nil tmp)))))
13032 13600
13033 (defvar org-property-changed-functions nil 13601 (defvar org-property-changed-functions nil
13034 "Hook called when the value of a property has changed. 13602 "Hook called when the value of a property has changed.
13035 Each hook function should accept two arguments, the name of the property 13603 Each hook function should accept two arguments, the name of the property
13036 and the new value.") 13604 and the new value.")
13225 13793
13226 (defun org-delete-property (property) 13794 (defun org-delete-property (property)
13227 "In the current entry, delete PROPERTY." 13795 "In the current entry, delete PROPERTY."
13228 (interactive 13796 (interactive
13229 (let* ((completion-ignore-case t) 13797 (let* ((completion-ignore-case t)
13230 (prop (org-icompleting-read "Property: " (org-entry-properties nil 'standard)))) 13798 (prop (org-icompleting-read "Property: "
13799 (org-entry-properties nil 'standard))))
13231 (list prop))) 13800 (list prop)))
13232 (message "Property %s %s" property 13801 (message "Property %s %s" property
13233 (if (org-entry-delete nil property) 13802 (if (org-entry-delete nil property)
13234 "deleted" 13803 "deleted"
13235 "was not present in the entry"))) 13804 "was not present in the entry")))
13338 (replace-match (concat " :" key ": " nval) t t) 13907 (replace-match (concat " :" key ": " nval) t t)
13339 (org-indent-line-function) 13908 (org-indent-line-function)
13340 (beginning-of-line 1) 13909 (beginning-of-line 1)
13341 (skip-chars-forward " \t") 13910 (skip-chars-forward " \t")
13342 (run-hook-with-args 'org-property-changed-functions key nval))) 13911 (run-hook-with-args 'org-property-changed-functions key nval)))
13912
13913 (defun org-find-olp (path &optional this-buffer)
13914 "Return a marker pointing to the entry at outline path OLP.
13915 If anything goes wrong, throw an error.
13916 You can wrap this call to catch the error like this:
13917
13918 (condition-case msg
13919 (org-mobile-locate-entry (match-string 4))
13920 (error (nth 1 msg)))
13921
13922 The return value will then be either a string with the error message,
13923 or a marker if everything is OK.
13924
13925 If THIS-BUFFER is set, the outline path does not contain a file,
13926 only headings."
13927 (let* ((file (if this-buffer buffer-file-name (pop path)))
13928 (buffer (if this-buffer (current-buffer) (find-file-noselect file)))
13929 (level 1)
13930 (lmin 1)
13931 (lmax 1)
13932 limit re end found pos heading cnt)
13933 (unless buffer (error "File not found :%s" file))
13934 (with-current-buffer buffer
13935 (save-excursion
13936 (save-restriction
13937 (widen)
13938 (setq limit (point-max))
13939 (goto-char (point-min))
13940 (while (setq heading (pop path))
13941 (setq re (format org-complex-heading-regexp-format
13942 (regexp-quote heading)))
13943 (setq cnt 0 pos (point))
13944 (while (re-search-forward re end t)
13945 (setq level (- (match-end 1) (match-beginning 1)))
13946 (if (and (>= level lmin) (<= level lmax))
13947 (setq found (match-beginning 0) cnt (1+ cnt))))
13948 (when (= cnt 0) (error "Heading not found on level %d: %s"
13949 lmax heading))
13950 (when (> cnt 1) (error "Heading not unique on level %d: %s"
13951 lmax heading))
13952 (goto-char found)
13953 (setq lmin (1+ level) lmax (+ lmin (if org-odd-levels-only 1 0)))
13954 (setq end (save-excursion (org-end-of-subtree t t))))
13955 (when (org-on-heading-p)
13956 (move-marker (make-marker) (point))))))))
13343 13957
13344 (defun org-find-entry-with-id (ident) 13958 (defun org-find-entry-with-id (ident)
13345 "Locate the entry that contains the ID property with exact value IDENT. 13959 "Locate the entry that contains the ID property with exact value IDENT.
13346 IDENT can be a string, a symbol or a number, this function will search for 13960 IDENT can be a string, a symbol or a number, this function will search for
13347 the string representation of it. 13961 the string representation of it.
13445 does not link to the calendar and cannot be changed with the S-cursor keys. 14059 does not link to the calendar and cannot be changed with the S-cursor keys.
13446 So these are more for recording a certain time/date." 14060 So these are more for recording a certain time/date."
13447 (interactive "P") 14061 (interactive "P")
13448 (org-time-stamp arg 'inactive)) 14062 (org-time-stamp arg 'inactive))
13449 14063
13450 (defvar org-date-ovl (org-make-overlay 1 1)) 14064 (defvar org-date-ovl (make-overlay 1 1))
13451 (org-overlay-put org-date-ovl 'face 'org-warning) 14065 (overlay-put org-date-ovl 'face 'org-warning)
13452 (org-detach-overlay org-date-ovl) 14066 (org-detach-overlay org-date-ovl)
13453 14067
13454 (defvar org-ans1) ; dynamically scoped parameter 14068 (defvar org-ans1) ; dynamically scoped parameter
13455 (defvar org-ans2) ; dynamically scoped parameter 14069 (defvar org-ans2) ; dynamically scoped parameter
13456 14070
13467 "Read a date, possibly a time, and make things smooth for the user. 14081 "Read a date, possibly a time, and make things smooth for the user.
13468 The prompt will suggest to enter an ISO date, but you can also enter anything 14082 The prompt will suggest to enter an ISO date, but you can also enter anything
13469 which will at least partially be understood by `parse-time-string'. 14083 which will at least partially be understood by `parse-time-string'.
13470 Unrecognized parts of the date will default to the current day, month, year, 14084 Unrecognized parts of the date will default to the current day, month, year,
13471 hour and minute. If this command is called to replace a timestamp at point, 14085 hour and minute. If this command is called to replace a timestamp at point,
13472 of to enter the second timestamp of a range, the default time is taken from the 14086 of to enter the second timestamp of a range, the default time is taken
13473 existing stamp. For example, 14087 from the existing stamp. Furthermore, the command prefers the future,
14088 so if you are giving a date where the year is not given, and the day-month
14089 combination is already past in the current year, it will assume you
14090 mean next year. For details, see the manual. A few examples:
14091
13474 3-2-5 --> 2003-02-05 14092 3-2-5 --> 2003-02-05
13475 feb 15 --> currentyear-02-15 14093 feb 15 --> currentyear-02-15
14094 2/15 --> currentyear-02-15
13476 sep 12 9 --> 2009-09-12 14095 sep 12 9 --> 2009-09-12
13477 12:45 --> today 12:45 14096 12:45 --> today 12:45
13478 22 sept 0:34 --> currentyear-09-22 0:34 14097 22 sept 0:34 --> currentyear-09-22 0:34
13479 12 --> currentyear-currentmonth-12 14098 12 --> currentyear-currentmonth-12
13480 Fri --> nearest Friday (today or later) 14099 Fri --> nearest Friday (today or later)
13523 (setcar (nthcdr 2 defdecode) -1) 14142 (setcar (nthcdr 2 defdecode) -1)
13524 (setcar (nthcdr 1 defdecode) 59) 14143 (setcar (nthcdr 1 defdecode) 59)
13525 (setq def (apply 'encode-time defdecode) 14144 (setq def (apply 'encode-time defdecode)
13526 defdecode (decode-time def))))) 14145 defdecode (decode-time def)))))
13527 (calendar-frame-setup nil) 14146 (calendar-frame-setup nil)
14147 (calendar-setup nil)
13528 (calendar-move-hook nil) 14148 (calendar-move-hook nil)
13529 (calendar-view-diary-initially-flag nil) 14149 (calendar-view-diary-initially-flag nil)
13530 (calendar-view-holidays-initially-flag nil) 14150 (calendar-view-holidays-initially-flag nil)
13531 (timestr (format-time-string 14151 (timestr (format-time-string
13532 (if with-time "%Y-%m-%d %H:%M" "%Y-%m-%d") def)) 14152 (if with-time "%Y-%m-%d %H:%M" "%Y-%m-%d") def))
13546 (org-eval-in-calendar nil t) 14166 (org-eval-in-calendar nil t)
13547 (let* ((old-map (current-local-map)) 14167 (let* ((old-map (current-local-map))
13548 (map (copy-keymap calendar-mode-map)) 14168 (map (copy-keymap calendar-mode-map))
13549 (minibuffer-local-map (copy-keymap minibuffer-local-map))) 14169 (minibuffer-local-map (copy-keymap minibuffer-local-map)))
13550 (org-defkey map (kbd "RET") 'org-calendar-select) 14170 (org-defkey map (kbd "RET") 'org-calendar-select)
13551 (org-defkey map (if (featurep 'xemacs) [button1] [mouse-1]) 14171 (org-defkey map [mouse-1] 'org-calendar-select-mouse)
13552 'org-calendar-select-mouse) 14172 (org-defkey map [mouse-2] 'org-calendar-select-mouse)
13553 (org-defkey map (if (featurep 'xemacs) [button2] [mouse-2])
13554 'org-calendar-select-mouse)
13555 (org-defkey minibuffer-local-map [(meta shift left)] 14173 (org-defkey minibuffer-local-map [(meta shift left)]
13556 (lambda () (interactive) 14174 (lambda () (interactive)
13557 (org-eval-in-calendar '(calendar-backward-month 1)))) 14175 (org-eval-in-calendar '(calendar-backward-month 1))))
13558 (org-defkey minibuffer-local-map [(meta shift right)] 14176 (org-defkey minibuffer-local-map [(meta shift right)]
13559 (lambda () (interactive) 14177 (lambda () (interactive)
13592 (lambda () (interactive) 14210 (lambda () (interactive)
13593 (org-eval-in-calendar '(scroll-calendar-left 1)))) 14211 (org-eval-in-calendar '(scroll-calendar-left 1))))
13594 (org-defkey minibuffer-local-map "<" 14212 (org-defkey minibuffer-local-map "<"
13595 (lambda () (interactive) 14213 (lambda () (interactive)
13596 (org-eval-in-calendar '(scroll-calendar-right 1)))) 14214 (org-eval-in-calendar '(scroll-calendar-right 1))))
14215 (org-defkey minibuffer-local-map "\C-v"
14216 (lambda () (interactive)
14217 (org-eval-in-calendar
14218 '(calendar-scroll-left-three-months 1))))
14219 (org-defkey minibuffer-local-map "\M-v"
14220 (lambda () (interactive)
14221 (org-eval-in-calendar
14222 '(calendar-scroll-right-three-months 1))))
13597 (run-hooks 'org-read-date-minibuffer-setup-hook) 14223 (run-hooks 'org-read-date-minibuffer-setup-hook)
13598 (unwind-protect 14224 (unwind-protect
13599 (progn 14225 (progn
13600 (use-local-map map) 14226 (use-local-map map)
13601 (add-hook 'post-command-hook 'org-read-date-display) 14227 (add-hook 'post-command-hook 'org-read-date-display)
13606 ;; org-ans2: from calendar motion 14232 ;; org-ans2: from calendar motion
13607 (setq ans (concat org-ans0 " " (or org-ans1 org-ans2)))) 14233 (setq ans (concat org-ans0 " " (or org-ans1 org-ans2))))
13608 (remove-hook 'post-command-hook 'org-read-date-display) 14234 (remove-hook 'post-command-hook 'org-read-date-display)
13609 (use-local-map old-map) 14235 (use-local-map old-map)
13610 (when org-read-date-overlay 14236 (when org-read-date-overlay
13611 (org-delete-overlay org-read-date-overlay) 14237 (delete-overlay org-read-date-overlay)
13612 (setq org-read-date-overlay nil))))))) 14238 (setq org-read-date-overlay nil)))))))
13613 14239
13614 (t ; Naked prompt only 14240 (t ; Naked prompt only
13615 (unwind-protect 14241 (unwind-protect
13616 (setq ans (read-string prompt default-input 14242 (setq ans (read-string prompt default-input
13617 'org-read-date-history timestr)) 14243 'org-read-date-history timestr))
13618 (when org-read-date-overlay 14244 (when org-read-date-overlay
13619 (org-delete-overlay org-read-date-overlay) 14245 (delete-overlay org-read-date-overlay)
13620 (setq org-read-date-overlay nil))))) 14246 (setq org-read-date-overlay nil)))))
13621 14247
13622 (setq final (org-read-date-analyze ans def defdecode)) 14248 (setq final (org-read-date-analyze ans def defdecode))
13623 (setq org-read-date-final-answer ans) 14249 (setq org-read-date-final-answer ans)
13624 14250
13636 (defvar org-read-date-analyze-futurep nil) 14262 (defvar org-read-date-analyze-futurep nil)
13637 (defun org-read-date-display () 14263 (defun org-read-date-display ()
13638 "Display the current date prompt interpretation in the minibuffer." 14264 "Display the current date prompt interpretation in the minibuffer."
13639 (when org-read-date-display-live 14265 (when org-read-date-display-live
13640 (when org-read-date-overlay 14266 (when org-read-date-overlay
13641 (org-delete-overlay org-read-date-overlay)) 14267 (delete-overlay org-read-date-overlay))
13642 (let ((p (point))) 14268 (let ((p (point)))
13643 (end-of-line 1) 14269 (end-of-line 1)
13644 (while (not (equal (buffer-substring 14270 (while (not (equal (buffer-substring
13645 (max (point-min) (- (point) 4)) (point)) 14271 (max (point-min) (- (point) 4)) (point))
13646 " ")) 14272 " "))
13664 org-end-time-was-given 14290 org-end-time-was-given
13665 (substring txt (match-end 0))))) 14291 (substring txt (match-end 0)))))
13666 (when org-read-date-analyze-futurep 14292 (when org-read-date-analyze-futurep
13667 (setq txt (concat txt " (=>F)"))) 14293 (setq txt (concat txt " (=>F)")))
13668 (setq org-read-date-overlay 14294 (setq org-read-date-overlay
13669 (org-make-overlay (1- (point-at-eol)) (point-at-eol))) 14295 (make-overlay (1- (point-at-eol)) (point-at-eol)))
13670 (org-overlay-display org-read-date-overlay txt 'secondary-selection)))) 14296 (org-overlay-display org-read-date-overlay txt 'secondary-selection))))
13671 14297
13672 (defun org-read-date-analyze (ans def defdecode) 14298 (defun org-read-date-analyze (ans def defdecode)
13673 "Analyse the combined answer of the date prompt." 14299 "Analyze the combined answer of the date prompt."
13674 ;; FIXME: cleanup and comment 14300 ;; FIXME: cleanup and comment
13675 (let ((nowdecode (decode-time (current-time))) 14301 (let ((nowdecode (decode-time (current-time)))
13676 delta deltan deltaw deltadef year month day 14302 delta deltan deltaw deltadef year month day
13677 hour minute second wday pm h2 m2 tl wday1 14303 hour minute second wday pm h2 m2 tl wday1
13678 iso-year iso-weekday iso-week iso-year iso-date futurep kill-year) 14304 iso-year iso-weekday iso-week iso-year iso-date futurep kill-year)
13710 (if (< year 100) (setq year (+ 2000 year))) 14336 (if (< year 100) (setq year (+ 2000 year)))
13711 (setq ans (replace-match (format "%04d-%02d-%02d\\5" year month day) 14337 (setq ans (replace-match (format "%04d-%02d-%02d\\5" year month day)
13712 t nil ans))) 14338 t nil ans)))
13713 ;; Help matching american dates, like 5/30 or 5/30/7 14339 ;; Help matching american dates, like 5/30 or 5/30/7
13714 (when (string-match 14340 (when (string-match
13715 "^ *\\([0-3]?[0-9]\\)/\\([0-1]?[0-9]\\)\\(/\\([0-9]+\\)\\)?\\([^/0-9]\\|$\\)" ans) 14341 "^ *\\(0?[1-9]\\|1[012]\\)/\\(0?[1-9]\\|[12][0-9]\\|3[01]\\)\\(/\\([0-9]+\\)\\)?\\([^/0-9]\\|$\\)" ans)
13716 (setq year (if (match-end 4) 14342 (setq year (if (match-end 4)
13717 (string-to-number (match-string 4 ans)) 14343 (string-to-number (match-string 4 ans))
13718 (progn (setq kill-year t) 14344 (progn (setq kill-year t)
13719 (string-to-number (format-time-string "%Y")))) 14345 (string-to-number (format-time-string "%Y"))))
13720 month (string-to-number (match-string 1 ans)) 14346 month (string-to-number (match-string 1 ans))
13900 (eval form) 14526 (eval form)
13901 (when (and (not keepdate) (calendar-cursor-to-date)) 14527 (when (and (not keepdate) (calendar-cursor-to-date))
13902 (let* ((date (calendar-cursor-to-date)) 14528 (let* ((date (calendar-cursor-to-date))
13903 (time (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date)))) 14529 (time (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date))))
13904 (setq org-ans2 (format-time-string "%Y-%m-%d" time)))) 14530 (setq org-ans2 (format-time-string "%Y-%m-%d" time))))
13905 (org-move-overlay org-date-ovl (1- (point)) (1+ (point)) (current-buffer)) 14531 (move-overlay org-date-ovl (1- (point)) (1+ (point)) (current-buffer))
13906 (select-window sw) 14532 (select-window sw)
13907 (org-select-frame-set-input-focus sf))) 14533 (org-select-frame-set-input-focus sf)))
13908 14534
13909 (defun org-calendar-select () 14535 (defun org-calendar-select ()
13910 "Return to `org-read-date' with the date currently selected. 14536 "Return to `org-read-date' with the date currently selected.
14194 (defun org-time-string-to-seconds (s) 14820 (defun org-time-string-to-seconds (s)
14195 (org-float-time (org-time-string-to-time s))) 14821 (org-float-time (org-time-string-to-time s)))
14196 14822
14197 (defun org-time-string-to-absolute (s &optional daynr prefer show-all) 14823 (defun org-time-string-to-absolute (s &optional daynr prefer show-all)
14198 "Convert a time stamp to an absolute day number. 14824 "Convert a time stamp to an absolute day number.
14199 If there is a specifyer for a cyclic time stamp, get the closest date to 14825 If there is a specifier for a cyclic time stamp, get the closest date to
14200 DAYNR. 14826 DAYNR.
14201 PREFER and SHOW-ALL are passed through to `org-closest-date'. 14827 PREFER and SHOW-ALL are passed through to `org-closest-date'.
14202 the variable date is bound by the calendar when this is called." 14828 the variable date is bound by the calendar when this is called."
14203 (cond 14829 (cond
14204 ((and daynr (string-match "\\`%%\\((.*)\\)" s)) 14830 ((and daynr (string-match "\\`%%\\((.*)\\)" s))
14307 (if (<= cday sday) (throw 'exit sday)) 14933 (if (<= cday sday) (throw 'exit sday))
14308 14934
14309 (if (string-match "\\(\\+[0-9]+\\)\\([dwmy]\\)" change) 14935 (if (string-match "\\(\\+[0-9]+\\)\\([dwmy]\\)" change)
14310 (setq dn (string-to-number (match-string 1 change)) 14936 (setq dn (string-to-number (match-string 1 change))
14311 dw (cdr (assoc (match-string 2 change) a1))) 14937 dw (cdr (assoc (match-string 2 change) a1)))
14312 (error "Invalid change specifyer: %s" change)) 14938 (error "Invalid change specifier: %s" change))
14313 (if (eq dw 'week) (setq dw 'day dn (* 7 dn))) 14939 (if (eq dw 'week) (setq dw 'day dn (* 7 dn)))
14314 (cond 14940 (cond
14315 ((eq dw 'day) 14941 ((eq dw 'day)
14316 (setq n1 (+ sday (* dn (floor (/ (- cday sday) dn)))) 14942 (setq n1 (+ sday (* dn (floor (/ (- cday sday) dn))))
14317 n2 (+ n1 dn))) 14943 n2 (+ n1 dn)))
14353 ((eq prefer 'past) (if (= cday n2) n2 n1)) 14979 ((eq prefer 'past) (if (= cday n2) n2 n1))
14354 ((eq prefer 'future) (if (= cday n1) n1 n2)) 14980 ((eq prefer 'future) (if (= cday n1) n1 n2))
14355 (t (if (= cday n1) n1 n2))))))) 14981 (t (if (= cday n1) n1 n2)))))))
14356 14982
14357 (defun org-date-to-gregorian (date) 14983 (defun org-date-to-gregorian (date)
14358 "Turn any specification of DATE into a gregorian date for the calendar." 14984 "Turn any specification of DATE into a Gregorian date for the calendar."
14359 (cond ((integerp date) (calendar-gregorian-from-absolute date)) 14985 (cond ((integerp date) (calendar-gregorian-from-absolute date))
14360 ((and (listp date) (= (length date) 3)) date) 14986 ((and (listp date) (= (length date) 3)) date)
14361 ((stringp date) 14987 ((stringp date)
14362 (setq date (org-parse-time-string date)) 14988 (setq date (org-parse-time-string date))
14363 (list (nth 4 date) (nth 3 date) (nth 5 date))) 14989 (list (nth 4 date) (nth 3 date) (nth 5 date)))
14385 "Increase the date item at the cursor by one. 15011 "Increase the date item at the cursor by one.
14386 If the cursor is on the year, change the year. If it is on the month or 15012 If the cursor is on the year, change the year. If it is on the month or
14387 the day, change that. 15013 the day, change that.
14388 With prefix ARG, change by that many units." 15014 With prefix ARG, change by that many units."
14389 (interactive "p") 15015 (interactive "p")
14390 (org-timestamp-change (prefix-numeric-value arg))) 15016 (org-timestamp-change (prefix-numeric-value arg) nil 'updown))
14391 15017
14392 (defun org-timestamp-down (&optional arg) 15018 (defun org-timestamp-down (&optional arg)
14393 "Decrease the date item at the cursor by one. 15019 "Decrease the date item at the cursor by one.
14394 If the cursor is on the year, change the year. If it is on the month or 15020 If the cursor is on the year, change the year. If it is on the month or
14395 the day, change that. 15021 the day, change that.
14396 With prefix ARG, change by that many units." 15022 With prefix ARG, change by that many units."
14397 (interactive "p") 15023 (interactive "p")
14398 (org-timestamp-change (- (prefix-numeric-value arg)))) 15024 (org-timestamp-change (- (prefix-numeric-value arg)) nil 'updown))
14399 15025
14400 (defun org-timestamp-up-day (&optional arg) 15026 (defun org-timestamp-up-day (&optional arg)
14401 "Increase the date in the time stamp by one day. 15027 "Increase the date in the time stamp by one day.
14402 With prefix ARG, change that many days." 15028 With prefix ARG, change that many days."
14403 (interactive "p") 15029 (interactive "p")
14404 (if (and (not (org-at-timestamp-p t)) 15030 (if (and (not (org-at-timestamp-p t))
14405 (org-on-heading-p)) 15031 (org-on-heading-p))
14406 (org-todo 'up) 15032 (org-todo 'up)
14407 (org-timestamp-change (prefix-numeric-value arg) 'day))) 15033 (org-timestamp-change (prefix-numeric-value arg) 'day 'updown)))
14408 15034
14409 (defun org-timestamp-down-day (&optional arg) 15035 (defun org-timestamp-down-day (&optional arg)
14410 "Decrease the date in the time stamp by one day. 15036 "Decrease the date in the time stamp by one day.
14411 With prefix ARG, change that many days." 15037 With prefix ARG, change that many days."
14412 (interactive "p") 15038 (interactive "p")
14413 (if (and (not (org-at-timestamp-p t)) 15039 (if (and (not (org-at-timestamp-p t))
14414 (org-on-heading-p)) 15040 (org-on-heading-p))
14415 (org-todo 'down) 15041 (org-todo 'down)
14416 (org-timestamp-change (- (prefix-numeric-value arg)) 'day))) 15042 (org-timestamp-change (- (prefix-numeric-value arg)) 'day) 'updown))
14417 15043
14418 (defun org-at-timestamp-p (&optional inactive-ok) 15044 (defun org-at-timestamp-p (&optional inactive-ok)
14419 "Determine if the cursor is in or at a timestamp." 15045 "Determine if the cursor is in or at a timestamp."
14420 (interactive) 15046 (interactive)
14421 (let* ((tsr (if inactive-ok org-ts-regexp3 org-ts-regexp2)) 15047 (let* ((tsr (if inactive-ok org-ts-regexp3 org-ts-regexp2))
14456 (replace-match (cdr (assoc (char-after (match-beginning 0)) map)) 15082 (replace-match (cdr (assoc (char-after (match-beginning 0)) map))
14457 t t))) 15083 t t)))
14458 (message "Timestamp is now %sactive" 15084 (message "Timestamp is now %sactive"
14459 (if (equal (char-after beg) ?<) "" "in"))))) 15085 (if (equal (char-after beg) ?<) "" "in")))))
14460 15086
14461 (defun org-timestamp-change (n &optional what) 15087 (defun org-timestamp-change (n &optional what updown)
14462 "Change the date in the time stamp at point. 15088 "Change the date in the time stamp at point.
14463 The date will be changed by N times WHAT. WHAT can be `day', `month', 15089 The date will be changed by N times WHAT. WHAT can be `day', `month',
14464 `year', `minute', `second'. If WHAT is not given, the cursor position 15090 `year', `minute', `second'. If WHAT is not given, the cursor position
14465 in the timestamp determines what will be changed." 15091 in the timestamp determines what will be changed."
14466 (let ((pos (point)) 15092 (let ((pos (point))
14487 ts) 15113 ts)
14488 (setq extra (match-string 1 ts))) 15114 (setq extra (match-string 1 ts)))
14489 (if (string-match "^.\\{10\\}.*?[0-9]+:[0-9][0-9]" ts) 15115 (if (string-match "^.\\{10\\}.*?[0-9]+:[0-9][0-9]" ts)
14490 (setq with-hm t)) 15116 (setq with-hm t))
14491 (setq time0 (org-parse-time-string ts)) 15117 (setq time0 (org-parse-time-string ts))
14492 (when (and (eq org-ts-what 'minute) 15118 (when (and updown
14493 (eq current-prefix-arg nil)) 15119 (eq org-ts-what 'minute)
15120 (not current-prefix-arg))
15121 ;; This looks like s-up and s-down. Change by one rounding step.
14494 (setq n (* dm (cond ((> n 0) 1) ((< n 0) -1) (t 0)))) 15122 (setq n (* dm (cond ((> n 0) 1) ((< n 0) -1) (t 0))))
14495 (when (not (= 0 (setq rem (% (nth 1 time0) dm)))) 15123 (when (not (= 0 (setq rem (% (nth 1 time0) dm))))
14496 (setcar (cdr time0) (+ (nth 1 time0) 15124 (setcar (cdr time0) (+ (nth 1 time0)
14497 (if (> n 0) (- rem) (- dm rem)))))) 15125 (if (> n 0) (- rem) (- dm rem))))))
14498 (setq time 15126 (setq time
14675 (org-id-locations-load))))) 15303 (org-id-locations-load)))))
14676 15304
14677 ;;;; Agenda files 15305 ;;;; Agenda files
14678 15306
14679 ;;;###autoload 15307 ;;;###autoload
14680 (defun org-iswitchb (&optional arg) 15308 (defun org-switchb (&optional arg)
14681 "Use `org-icompleting-read' to prompt for an Org buffer to switch to. 15309 "Switch between Org buffers.
14682 With a prefix argument, restrict available to files. 15310 With a prefix argument, restrict available to files.
14683 With two prefix arguments, restrict available buffers to agenda files." 15311 With two prefix arguments, restrict available buffers to agenda files.
15312
15313 Defaults to `iswitchb' for buffer name completion.
15314 Set `org-completion-use-ido' to make it use ido instead."
14684 (interactive "P") 15315 (interactive "P")
14685 (let ((blist (cond ((equal arg '(4)) (org-buffer-list 'files)) 15316 (let ((blist (cond ((equal arg '(4)) (org-buffer-list 'files))
14686 ((equal arg '(16)) (org-buffer-list 'agenda)) 15317 ((equal arg '(16)) (org-buffer-list 'agenda))
14687 (t (org-buffer-list))))) 15318 (t (org-buffer-list))))
15319 (org-completion-use-iswitchb org-completion-use-iswitchb)
15320 (org-completion-use-ido org-completion-use-ido))
15321 (unless (or org-completion-use-ido org-completion-use-iswitchb)
15322 (setq org-completion-use-iswitchb t))
14688 (switch-to-buffer 15323 (switch-to-buffer
14689 (org-icompleting-read "Org buffer: " 15324 (org-icompleting-read "Org buffer: "
14690 (mapcar 'list (mapcar 'buffer-name blist)) 15325 (mapcar 'list (mapcar 'buffer-name blist))
14691 nil t)))) 15326 nil t))))
14692 15327
15328 ;;; Define some older names previously used for this functionality
14693 ;;;###autoload 15329 ;;;###autoload
14694 (defalias 'org-ido-switchb 'org-iswitchb) 15330 (defalias 'org-ido-switchb 'org-switchb)
15331 ;;;###autoload
15332 (defalias 'org-iswitchb 'org-switchb)
14695 15333
14696 (defun org-buffer-list (&optional predicate exclude-tmp) 15334 (defun org-buffer-list (&optional predicate exclude-tmp)
14697 "Return a list of Org buffers. 15335 "Return a list of Org buffers.
14698 PREDICATE can be `export', `files' or `agenda'. 15336 PREDICATE can be `export', `files' or `agenda'.
14699 15337
14759 files)))) 15397 files))))
14760 (when (or (eq archives t) 15398 (when (or (eq archives t)
14761 (and (eq archives 'ifmode) (eq org-agenda-archives-mode t))) 15399 (and (eq archives 'ifmode) (eq org-agenda-archives-mode t)))
14762 (setq files (org-add-archive-files files))) 15400 (setq files (org-add-archive-files files)))
14763 files)) 15401 files))
15402
15403 (defun org-agenda-file-p (&optional file)
15404 "Return non-nil, if FILE is an agenda file.
15405 If FILE is omitted, use the file associated with the current
15406 buffer."
15407 (member (or file (buffer-file-name))
15408 (org-agenda-files t)))
14764 15409
14765 (defun org-edit-agenda-file-list () 15410 (defun org-edit-agenda-file-list ()
14766 "Edit the list of agenda files. 15411 "Edit the list of agenda files.
14767 Depending on setup, this either uses customize to edit the variable 15412 Depending on setup, this either uses customize to edit the variable
14768 `org-agenda-files', or it visits the file that is holding the list. In the 15413 `org-agenda-files', or it visits the file that is holding the list. In the
15073 "Is point inside a LaTeX macro or its arguments?" 15718 "Is point inside a LaTeX macro or its arguments?"
15074 (save-match-data 15719 (save-match-data
15075 (org-in-regexp 15720 (org-in-regexp
15076 "\\\\[a-zA-Z]+\\*?\\(\\(\\[[^][\n{}]*\\]\\)\\|\\({[^{}\n]*}\\)\\)*"))) 15721 "\\\\[a-zA-Z]+\\*?\\(\\(\\[[^][\n{}]*\\]\\)\\|\\({[^{}\n]*}\\)\\)*")))
15077 15722
15078 (defun test ()
15079 (interactive)
15080 (message "%s" (org-inside-latex-macro-p)))
15081
15082 (defun org-try-cdlatex-tab () 15723 (defun org-try-cdlatex-tab ()
15083 "Check if it makes sense to execute `cdlatex-tab', and do it if yes. 15724 "Check if it makes sense to execute `cdlatex-tab', and do it if yes.
15084 It makes sense to do so if `org-cdlatex-mode' is active and if the cursor is 15725 It makes sense to do so if `org-cdlatex-mode' is active and if the cursor is
15085 - inside a LaTeX fragment, or 15726 - inside a LaTeX fragment, or
15086 - after the first word in a line, where an abbreviation expansion could 15727 - after the first word in a line, where an abbreviation expansion could
15118 "List of overlays carrying the images of latex fragments.") 15759 "List of overlays carrying the images of latex fragments.")
15119 (make-variable-buffer-local 'org-latex-fragment-image-overlays) 15760 (make-variable-buffer-local 'org-latex-fragment-image-overlays)
15120 15761
15121 (defun org-remove-latex-fragment-image-overlays () 15762 (defun org-remove-latex-fragment-image-overlays ()
15122 "Remove all overlays with LaTeX fragment images in current buffer." 15763 "Remove all overlays with LaTeX fragment images in current buffer."
15123 (mapc 'org-delete-overlay org-latex-fragment-image-overlays) 15764 (mapc 'delete-overlay org-latex-fragment-image-overlays)
15124 (setq org-latex-fragment-image-overlays nil)) 15765 (setq org-latex-fragment-image-overlays nil))
15125 15766
15126 (defun org-preview-latex-fragment (&optional subtree) 15767 (defun org-preview-latex-fragment (&optional subtree)
15127 "Preview the LaTeX fragment at point, or all locally or globally. 15768 "Preview the LaTeX fragment at point, or all locally or globally.
15128 If the cursor is in a LaTeX fragment, create the image and overlay 15769 If the cursor is in a LaTeX fragment, create the image and overlay
15129 it over the source code. If there is no fragment at point, display 15770 it over the source code. If there is no fragment at point, display
15130 all fragments in the current text, from one headline to the next. With 15771 all fragments in the current text, from one headline to the next. With
15131 prefix SUBTREE, display all fragments in the current subtree. With a 15772 prefix SUBTREE, display all fragments in the current subtree. With a
15132 double prefix `C-u C-u', or when the cursor is before the first headline, 15773 double prefix arg \\[universal-argument] \\[universal-argument], or when \
15774 the cursor is before the first headline,
15133 display all fragments in the buffer. 15775 display all fragments in the buffer.
15134 The images can be removed again with \\[org-ctrl-c-ctrl-c]." 15776 The images can be removed again with \\[org-ctrl-c-ctrl-c]."
15135 (interactive "P") 15777 (interactive "P")
15136 (org-remove-latex-fragment-image-overlays) 15778 (org-remove-latex-fragment-image-overlays)
15137 (save-excursion 15779 (save-excursion
15173 ("\\(" "\\\\([^\000]*?\\\\)" 0 nil) 15815 ("\\(" "\\\\([^\000]*?\\\\)" 0 nil)
15174 ("\\[" "\\\\\\[[^\000]*?\\\\\\]" 0 nil) 15816 ("\\[" "\\\\\\[[^\000]*?\\\\\\]" 0 nil)
15175 ("$$" "\\$\\$[^\000]*?\\$\\$" 0 nil)) 15817 ("$$" "\\$\\$[^\000]*?\\$\\$" 0 nil))
15176 "Regular expressions for matching embedded LaTeX.") 15818 "Regular expressions for matching embedded LaTeX.")
15177 15819
15178 (defun org-format-latex (prefix &optional dir overlays msg at forbuffer) 15820 (defun org-format-latex (prefix &optional dir overlays msg at
15821 forbuffer protect-only)
15179 "Replace LaTeX fragments with links to an image, and produce images. 15822 "Replace LaTeX fragments with links to an image, and produce images.
15180 Some of the options can be changed using the variable 15823 Some of the options can be changed using the variable
15181 `org-format-latex-options'." 15824 `org-format-latex-options'."
15182 (if (and overlays (fboundp 'clear-image-cache)) (clear-image-cache)) 15825 (if (and overlays (fboundp 'clear-image-cache)) (clear-image-cache))
15183 (let* ((prefixnodir (file-name-nondirectory prefix)) 15826 (let* ((prefixnodir (file-name-nondirectory prefix))
15203 'org-protected)) 15846 'org-protected))
15204 (or (not overlays) 15847 (or (not overlays)
15205 (not (eq (get-char-property (match-beginning n) 15848 (not (eq (get-char-property (match-beginning n)
15206 'org-overlay-type) 15849 'org-overlay-type)
15207 'org-latex-overlay)))) 15850 'org-latex-overlay))))
15208 (setq txt (match-string n) 15851 (if protect-only
15209 beg (match-beginning n) end (match-end n) 15852 (add-text-properties (match-beginning n) (match-end n)
15210 cnt (1+ cnt)) 15853 '(org-protected t))
15211 (let (print-length print-level) ; make sure full list is printed 15854 (setq txt (match-string n)
15212 (setq hash (sha1 (prin1-to-string 15855 beg (match-beginning n) end (match-end n)
15213 (list org-format-latex-header 15856 cnt (1+ cnt))
15214 org-format-latex-header-extra 15857 (let (print-length print-level) ; make sure full list is printed
15215 org-export-latex-default-packages-alist 15858 (setq hash (sha1 (prin1-to-string
15216 org-export-latex-packages-alist 15859 (list org-format-latex-header
15217 org-format-latex-options 15860 org-format-latex-header-extra
15218 forbuffer txt))) 15861 org-export-latex-default-packages-alist
15219 linkfile (format "%s_%s.png" prefix hash) 15862 org-export-latex-packages-alist
15220 movefile (format "%s_%s.png" absprefix hash))) 15863 org-format-latex-options
15221 (setq link (concat block "[[file:" linkfile "]]" block)) 15864 forbuffer txt)))
15222 (if msg (message msg cnt)) 15865 linkfile (format "%s_%s.png" prefix hash)
15223 (goto-char beg) 15866 movefile (format "%s_%s.png" absprefix hash)))
15224 (unless checkdir ; make sure the directory exists 15867 (setq link (concat block "[[file:" linkfile "]]" block))
15225 (setq checkdir t) 15868 (if msg (message msg cnt))
15226 (or (file-directory-p todir) (make-directory todir))) 15869 (goto-char beg)
15227 15870 (unless checkdir ; make sure the directory exists
15228 (unless executables-checked 15871 (setq checkdir t)
15229 (org-check-external-command 15872 (or (file-directory-p todir) (make-directory todir)))
15230 "latex" "needed to convert LaTeX fragments to images") 15873
15231 (org-check-external-command 15874 (unless executables-checked
15232 "dvipng" "needed to convert LaTeX fragments to images") 15875 (org-check-external-command
15233 (setq executables-checked t)) 15876 "latex" "needed to convert LaTeX fragments to images")
15234 15877 (org-check-external-command
15235 (unless (file-exists-p movefile) 15878 "dvipng" "needed to convert LaTeX fragments to images")
15236 (org-create-formula-image 15879 (setq executables-checked t))
15237 txt movefile opt forbuffer)) 15880
15238 (if overlays 15881 (unless (file-exists-p movefile)
15239 (progn 15882 (org-create-formula-image
15240 (mapc (lambda (o) 15883 txt movefile opt forbuffer))
15241 (if (eq (org-overlay-get o 'org-overlay-type) 15884 (if overlays
15242 'org-latex-overlay) 15885 (progn
15243 (org-delete-overlay o))) 15886 (mapc (lambda (o)
15244 (org-overlays-in beg end)) 15887 (if (eq (overlay-get o 'org-overlay-type)
15245 (setq ov (org-make-overlay beg end)) 15888 'org-latex-overlay)
15246 (org-overlay-put ov 'org-overlay-type 'org-latex-overlay) 15889 (delete-overlay o)))
15247 (if (featurep 'xemacs) 15890 (overlays-in beg end))
15248 (progn 15891 (setq ov (make-overlay beg end))
15249 (org-overlay-put ov 'invisible t) 15892 (overlay-put ov 'org-overlay-type 'org-latex-overlay)
15250 (org-overlay-put 15893 (if (featurep 'xemacs)
15251 ov 'end-glyph 15894 (progn
15252 (make-glyph (vector 'png :file movefile)))) 15895 (overlay-put ov 'invisible t)
15253 (org-overlay-put 15896 (overlay-put
15254 ov 'display 15897 ov 'end-glyph
15255 (list 'image :type 'png :file movefile :ascent 'center))) 15898 (make-glyph (vector 'png :file movefile))))
15256 (push ov org-latex-fragment-image-overlays) 15899 (overlay-put
15257 (goto-char end)) 15900 ov 'display
15258 (delete-region beg end) 15901 (list 'image :type 'png :file movefile :ascent 'center)))
15259 (insert (org-add-props link 15902 (push ov org-latex-fragment-image-overlays)
15260 (list 'org-latex-src 15903 (goto-char end))
15261 (replace-regexp-in-string "\"" "" txt))))))))))) 15904 (delete-region beg end)
15905 (insert (org-add-props link
15906 (list 'org-latex-src
15907 (replace-regexp-in-string "\"" "" txt))))))))))))
15262 15908
15263 ;; This function borrows from Ganesh Swami's latex2png.el 15909 ;; This function borrows from Ganesh Swami's latex2png.el
15264 (defun org-create-formula-image (string tofile options buffer) 15910 (defun org-create-formula-image (string tofile options buffer)
15265 "This calls dvipng." 15911 "This calls dvipng."
15266 (require 'org-latex) 15912 (require 'org-latex)
15285 (if (eq bg 'default) (setq bg (org-dvipng-color :background))) 15931 (if (eq bg 'default) (setq bg (org-dvipng-color :background)))
15286 (with-temp-file texfile 15932 (with-temp-file texfile
15287 (insert (org-splice-latex-header 15933 (insert (org-splice-latex-header
15288 org-format-latex-header 15934 org-format-latex-header
15289 org-export-latex-default-packages-alist 15935 org-export-latex-default-packages-alist
15290 org-export-latex-packages-alist 15936 org-export-latex-packages-alist t
15291 org-format-latex-header-extra)) 15937 org-format-latex-header-extra))
15292 (insert "\n\\begin{document}\n" string "\n\\end{document}\n") 15938 (insert "\n\\begin{document}\n" string "\n\\end{document}\n")
15293 (require 'org-latex) 15939 (require 'org-latex)
15294 (org-export-latex-fix-inputenc)) 15940 (org-export-latex-fix-inputenc))
15295 (let ((dir default-directory)) 15941 (let ((dir default-directory))
15319 (copy-file pngfile tofile 'replace) 15965 (copy-file pngfile tofile 'replace)
15320 (loop for e in '(".dvi" ".tex" ".aux" ".log" ".png") do 15966 (loop for e in '(".dvi" ".tex" ".aux" ".log" ".png") do
15321 (delete-file (concat texfilebase e))) 15967 (delete-file (concat texfilebase e)))
15322 pngfile)))) 15968 pngfile))))
15323 15969
15324 (defun org-splice-latex-header (tpl def-pkg pkg &optional extra) 15970 (defun org-splice-latex-header (tpl def-pkg pkg snippets-p &optional extra)
15325 "Fill a LaTeX header template TPL. 15971 "Fill a LaTeX header template TPL.
15326 In the template, the following place holders will be recognized: 15972 In the template, the following place holders will be recognized:
15327 15973
15328 [DEFAULT-PACKAGES] \\usepackage statements for DEF-PKG 15974 [DEFAULT-PACKAGES] \\usepackage statements for DEF-PKG
15329 [NO-DEFAULT-PACKAGES] do not include DEF-PKG 15975 [NO-DEFAULT-PACKAGES] do not include DEF-PKG
15330 [PACKAGES] \\usepackage statements for PKG 15976 [PACKAGES] \\usepackage statements for PKG
15331 [NO-PACKAGES] do not include PKG 15977 [NO-PACKAGES] do not include PKG
15332 [EXTRA] the string EXTRA 15978 [EXTRA] the string EXTRA
15333 [NO-EXTRA] do not include EXTRA 15979 [NO-EXTRA] do not include EXTRA
15334 15980
15335 For backward compatibility, if both the positive and the negative place 15981 For backward compatibility, if both the positive and the negative place
15336 holder is missing, the positive one (without the \"NO-\") will be 15982 holder is missing, the positive one (without the \"NO-\") will be
15337 assumed to be present at the end of the template. 15983 assumed to be present at the end of the template.
15338 DEF-PKG and PKG are assumed to be alists of options/packagename lists. 15984 DEF-PKG and PKG are assumed to be alists of options/packagename lists.
15339 EXTRA is a string." 15985 EXTRA is a string.
15986 SNIPPETS-P indicates if this is run to create snippet images for HTML."
15340 (let (rpl (end "")) 15987 (let (rpl (end ""))
15341 (if (string-match "^[ \t]*\\[\\(NO-\\)?DEFAULT-PACKAGES\\][ \t]*\n?" tpl) 15988 (if (string-match "^[ \t]*\\[\\(NO-\\)?DEFAULT-PACKAGES\\][ \t]*\n?" tpl)
15342 (setq rpl (if (or (match-end 1) (not def-pkg)) 15989 (setq rpl (if (or (match-end 1) (not def-pkg))
15343 "" (org-latex-packages-to-string def-pkg t)) 15990 "" (org-latex-packages-to-string def-pkg snippets-p t))
15344 tpl (replace-match rpl t t tpl)) 15991 tpl (replace-match rpl t t tpl))
15345 (if def-pkg (setq end (org-latex-packages-to-string def-pkg)))) 15992 (if def-pkg (setq end (org-latex-packages-to-string def-pkg snippets-p))))
15346 15993
15347 (if (string-match "\\[\\(NO-\\)?PACKAGES\\][ \t]*\n?" tpl) 15994 (if (string-match "\\[\\(NO-\\)?PACKAGES\\][ \t]*\n?" tpl)
15348 (setq rpl (if (or (match-end 1) (not pkg)) 15995 (setq rpl (if (or (match-end 1) (not pkg))
15349 "" (org-latex-packages-to-string pkg t)) 15996 "" (org-latex-packages-to-string pkg snippets-p t))
15350 tpl (replace-match rpl t t tpl)) 15997 tpl (replace-match rpl t t tpl))
15351 (if pkg (setq end (concat end "\n" (org-latex-packages-to-string pkg))))) 15998 (if pkg (setq end
15999 (concat end "\n"
16000 (org-latex-packages-to-string pkg snippets-p)))))
15352 16001
15353 (if (string-match "\\[\\(NO-\\)?EXTRA\\][ \t]*\n?" tpl) 16002 (if (string-match "\\[\\(NO-\\)?EXTRA\\][ \t]*\n?" tpl)
15354 (setq rpl (if (or (match-end 1) (not extra)) 16003 (setq rpl (if (or (match-end 1) (not extra))
15355 "" (concat extra "\n")) 16004 "" (concat extra "\n"))
15356 tpl (replace-match rpl t t tpl)) 16005 tpl (replace-match rpl t t tpl))
15359 16008
15360 (if (string-match "\\S-" end) 16009 (if (string-match "\\S-" end)
15361 (concat tpl "\n" end) 16010 (concat tpl "\n" end)
15362 tpl))) 16011 tpl)))
15363 16012
15364 (defun org-latex-packages-to-string (pkg &optional newline) 16013 (defun org-latex-packages-to-string (pkg &optional snippets-p newline)
15365 "Turn an alist of packages into a string with the \\usepackage macros." 16014 "Turn an alist of packages into a string with the \\usepackage macros."
15366 (setq pkg (mapconcat (lambda(p) 16015 (setq pkg (mapconcat (lambda(p)
15367 (cond 16016 (cond
15368 ((stringp p) p) 16017 ((stringp p) p)
16018 ((and snippets-p (>= (length p) 3) (not (nth 2 p)))
16019 (format "%% Package %s omitted" (cadr p)))
15369 ((equal "" (car p)) 16020 ((equal "" (car p))
15370 (format "\\usepackage{%s}" (cadr p))) 16021 (format "\\usepackage{%s}" (cadr p)))
15371 (t 16022 (t
15372 (format "\\usepackage[%s]{%s}" 16023 (format "\\usepackage[%s]{%s}"
15373 (car p) (cadr p))))) 16024 (car p) (cadr p)))))
15382 (color-values (face-attribute 'default attr nil))))) 16033 (color-values (face-attribute 'default attr nil)))))
15383 16034
15384 (defun org-normalize-color (value) 16035 (defun org-normalize-color (value)
15385 "Return string to be used as color value for an RGB component." 16036 "Return string to be used as color value for an RGB component."
15386 (format "%g" (/ value 65535.0))) 16037 (format "%g" (/ value 65535.0)))
16038
16039 ;; Image display
16040
16041
16042 (defvar org-inline-image-overlays nil)
16043 (make-variable-buffer-local 'org-inline-image-overlays)
16044
16045 (defun org-toggle-inline-images (&optional include-linked)
16046 "Toggle the display of inline images.
16047 INCLUDE-LINKED is passed to `org-display-inline-images'."
16048 (interactive "P")
16049 (if org-inline-image-overlays
16050 (progn
16051 (org-remove-inline-images)
16052 (message "Inline image display turned off"))
16053 (org-display-inline-images include-linked)
16054 (if org-inline-image-overlays
16055 (message "%d images displayed inline"
16056 (length org-inline-image-overlays))
16057 (message "No images to display inline"))))
16058
16059 (defun org-display-inline-images (&optional include-linked refresh beg end)
16060 "Display inline images.
16061 Normally only links without a description part are inlined, because this
16062 is how it will work for export. When INCLUDE-LINKED is set, also links
16063 with a description part will be inlined. This can be nice for a quick
16064 look at those images, but it does not reflect what exported files will look
16065 like.
16066 When REFRESH is set, refresh existing images between BEG and END.
16067 This will create new image displays only if necessary.
16068 BEG and END default to the buffer boundaries."
16069 (interactive "P")
16070 (unless refresh
16071 (org-remove-inline-images)
16072 (clear-image-cache))
16073 (save-excursion
16074 (save-restriction
16075 (widen)
16076 (setq beg (or beg (point-min)) end (or end (point-max)))
16077 (goto-char (point-min))
16078 (let ((re (concat "\\[\\[\\(\\(file:\\)\\|\\([./~]\\)\\)\\([-+~.:/\\_0-9a-zA-Z ]+"
16079 (substring (org-image-file-name-regexp) 0 -2)
16080 "\\)\\]" (if include-linked "" "\\]")))
16081 old file ov img)
16082 (while (re-search-forward re end t)
16083 (setq old (get-char-property-and-overlay (match-beginning 1)
16084 'org-image-overlay))
16085 (setq file (expand-file-name
16086 (concat (or (match-string 3) "") (match-string 4))))
16087 (when (file-exists-p file)
16088 (if (and (car-safe old) refresh)
16089 (image-refresh (overlay-get (cdr old) 'display))
16090 (setq img (create-image file))
16091 (when img
16092 (setq ov (make-overlay (match-beginning 0) (match-end 0)))
16093 (overlay-put ov 'display img)
16094 (overlay-put ov 'face 'default)
16095 (overlay-put ov 'org-image-overlay t)
16096 (overlay-put ov 'modification-hooks
16097 (list 'org-display-inline-modification-hook))
16098 (push ov org-inline-image-overlays)))))))))
16099
16100 (defun org-display-inline-modification-hook (ov after beg end &optional len)
16101 "Remove inline-display overlay if a corresponding region is modified."
16102 (let ((inhibit-modification-hooks t))
16103 (when (and ov after)
16104 (delete ov org-inline-image-overlays)
16105 (delete-overlay ov))))
16106
16107 (defun org-remove-inline-images ()
16108 "Remove inline display of images."
16109 (interactive)
16110 (mapc 'delete-overlay org-inline-image-overlays)
16111 (setq org-inline-image-overlays nil))
15387 16112
15388 ;;;; Key bindings 16113 ;;;; Key bindings
15389 16114
15390 ;; Make `C-c C-x' a prefix key 16115 ;; Make `C-c C-x' a prefix key
15391 (org-defkey org-mode-map "\C-c\C-x" (make-sparse-keymap)) 16116 (org-defkey org-mode-map "\C-c\C-x" (make-sparse-keymap))
15423 (org-defkey org-mode-map [(shift left)] 'org-shiftleft) 16148 (org-defkey org-mode-map [(shift left)] 'org-shiftleft)
15424 (org-defkey org-mode-map [(shift right)] 'org-shiftright) 16149 (org-defkey org-mode-map [(shift right)] 'org-shiftright)
15425 16150
15426 (org-defkey org-mode-map [(control shift right)] 'org-shiftcontrolright) 16151 (org-defkey org-mode-map [(control shift right)] 'org-shiftcontrolright)
15427 (org-defkey org-mode-map [(control shift left)] 'org-shiftcontrolleft) 16152 (org-defkey org-mode-map [(control shift left)] 'org-shiftcontrolleft)
16153
16154 ;; Babel keys
16155 (define-key org-mode-map org-babel-key-prefix org-babel-map)
16156 (mapc (lambda (pair)
16157 (define-key org-babel-map (car pair) (cdr pair)))
16158 org-babel-key-bindings)
15428 16159
15429 ;;; Extra keys for tty access. 16160 ;;; Extra keys for tty access.
15430 ;; We only set them when really needed because otherwise the 16161 ;; We only set them when really needed because otherwise the
15431 ;; menus don't show the simple keys 16162 ;; menus don't show the simple keys
15432 16163
15481 (org-defkey org-mode-map "\C-c\C-t" 'org-todo) 16212 (org-defkey org-mode-map "\C-c\C-t" 'org-todo)
15482 (org-defkey org-mode-map "\C-c\C-q" 'org-set-tags-command) 16213 (org-defkey org-mode-map "\C-c\C-q" 'org-set-tags-command)
15483 (org-defkey org-mode-map "\C-c\C-s" 'org-schedule) 16214 (org-defkey org-mode-map "\C-c\C-s" 'org-schedule)
15484 (org-defkey org-mode-map "\C-c\C-d" 'org-deadline) 16215 (org-defkey org-mode-map "\C-c\C-d" 'org-deadline)
15485 (org-defkey org-mode-map "\C-c;" 'org-toggle-comment) 16216 (org-defkey org-mode-map "\C-c;" 'org-toggle-comment)
15486 (org-defkey org-mode-map "\C-c\C-v" 'org-show-todo-tree)
15487 (org-defkey org-mode-map "\C-c\C-w" 'org-refile) 16217 (org-defkey org-mode-map "\C-c\C-w" 'org-refile)
15488 (org-defkey org-mode-map "\C-c/" 'org-sparse-tree) ; Minor-mode reserved 16218 (org-defkey org-mode-map "\C-c/" 'org-sparse-tree) ; Minor-mode reserved
15489 (org-defkey org-mode-map "\C-c\\" 'org-match-sparse-tree) ; Minor-mode res. 16219 (org-defkey org-mode-map "\C-c\\" 'org-match-sparse-tree) ; Minor-mode res.
15490 (org-defkey org-mode-map "\C-c\C-m" 'org-ctrl-c-ret) 16220 (org-defkey org-mode-map "\C-c\C-m" 'org-ctrl-c-ret)
15491 (org-defkey org-mode-map "\M-\C-m" 'org-insert-heading) 16221 (org-defkey org-mode-map "\M-\C-m" 'org-insert-heading)
15552 (org-defkey org-mode-map "\C-c\C-x\C-x" 'org-clock-cancel) 16282 (org-defkey org-mode-map "\C-c\C-x\C-x" 'org-clock-cancel)
15553 (org-defkey org-mode-map "\C-c\C-x\C-d" 'org-clock-display) 16283 (org-defkey org-mode-map "\C-c\C-x\C-d" 'org-clock-display)
15554 (org-defkey org-mode-map "\C-c\C-x\C-r" 'org-clock-report) 16284 (org-defkey org-mode-map "\C-c\C-x\C-r" 'org-clock-report)
15555 (org-defkey org-mode-map "\C-c\C-x\C-u" 'org-dblock-update) 16285 (org-defkey org-mode-map "\C-c\C-x\C-u" 'org-dblock-update)
15556 (org-defkey org-mode-map "\C-c\C-x\C-l" 'org-preview-latex-fragment) 16286 (org-defkey org-mode-map "\C-c\C-x\C-l" 'org-preview-latex-fragment)
16287 (org-defkey org-mode-map "\C-c\C-x\C-v" 'org-toggle-inline-images)
16288 (org-defkey org-mode-map "\C-c\C-x\\" 'org-toggle-pretty-entities)
15557 (org-defkey org-mode-map "\C-c\C-x\C-b" 'org-toggle-checkbox) 16289 (org-defkey org-mode-map "\C-c\C-x\C-b" 'org-toggle-checkbox)
15558 (org-defkey org-mode-map "\C-c\C-xp" 'org-set-property) 16290 (org-defkey org-mode-map "\C-c\C-xp" 'org-set-property)
15559 (org-defkey org-mode-map "\C-c\C-xe" 'org-set-effort) 16291 (org-defkey org-mode-map "\C-c\C-xe" 'org-set-effort)
15560 (org-defkey org-mode-map "\C-c\C-xo" 'org-toggle-ordered-property) 16292 (org-defkey org-mode-map "\C-c\C-xo" 'org-toggle-ordered-property)
15561 (org-defkey org-mode-map "\C-c\C-xi" 'org-insert-columns-dblock) 16293 (org-defkey org-mode-map "\C-c\C-xi" 'org-insert-columns-dblock)
15644 16376
15645 (defun org-speed-command-help () 16377 (defun org-speed-command-help ()
15646 "Show the available speed commands." 16378 "Show the available speed commands."
15647 (interactive) 16379 (interactive)
15648 (if (not org-use-speed-commands) 16380 (if (not org-use-speed-commands)
15649 (error "Speed commands are not activated, customize `org-use-speed-commands'.") 16381 (error "Speed commands are not activated, customize `org-use-speed-commands'")
15650 (with-output-to-temp-buffer "*Help*" 16382 (with-output-to-temp-buffer "*Help*"
15651 (princ "User-defined Speed commands\n===========================\n") 16383 (princ "User-defined Speed commands\n===========================\n")
15652 (mapc 'org-print-speed-command org-speed-commands-user) 16384 (mapc 'org-print-speed-command org-speed-commands-user)
15653 (princ "\n") 16385 (princ "\n")
15654 (princ "Built-in Speed commands\n=======================\n") 16386 (princ "Built-in Speed commands\n=======================\n")
15837 "Hook for functions to attach themselves to TAB. 16569 "Hook for functions to attach themselves to TAB.
15838 See `org-ctrl-c-ctrl-c-hook' for more information. 16570 See `org-ctrl-c-ctrl-c-hook' for more information.
15839 This hook runs as the first action when TAB is pressed, even before 16571 This hook runs as the first action when TAB is pressed, even before
15840 `org-cycle' messes around with the `outline-regexp' to cater for 16572 `org-cycle' messes around with the `outline-regexp' to cater for
15841 inline tasks and plain list item folding. 16573 inline tasks and plain list item folding.
15842 If any function in this hook returns t, not other actions like table 16574 If any function in this hook returns t, any other actions that
15843 field motion visibility cycling will be done.") 16575 would have been caused by TAB (such as table field motion or visibility
16576 cycling) will not occur.")
15844 16577
15845 (defvar org-tab-after-check-for-table-hook nil 16578 (defvar org-tab-after-check-for-table-hook nil
15846 "Hook for functions to attach themselves to TAB. 16579 "Hook for functions to attach themselves to TAB.
15847 See `org-ctrl-c-ctrl-c-hook' for more information. 16580 See `org-ctrl-c-ctrl-c-hook' for more information.
15848 This hook runs after it has been established that the cursor is not in a 16581 This hook runs after it has been established that the cursor is not in a
15889 "Hook for functions attaching themselves to `M-S-down'. 16622 "Hook for functions attaching themselves to `M-S-down'.
15890 See `org-ctrl-c-ctrl-c-hook' for more information.") 16623 See `org-ctrl-c-ctrl-c-hook' for more information.")
15891 (defvar org-metareturn-hook nil 16624 (defvar org-metareturn-hook nil
15892 "Hook for functions attaching themselves to `M-RET'. 16625 "Hook for functions attaching themselves to `M-RET'.
15893 See `org-ctrl-c-ctrl-c-hook' for more information.") 16626 See `org-ctrl-c-ctrl-c-hook' for more information.")
16627 (defvar org-shiftup-hook nil
16628 "Hook for functions attaching themselves to `S-up'.
16629 See `org-ctrl-c-ctrl-c-hook' for more information.")
16630 (defvar org-shiftup-final-hook nil
16631 "Hook for functions attaching themselves to `S-up'.
16632 This one runs after all other options except shift-select have been excluded.
16633 See `org-ctrl-c-ctrl-c-hook' for more information.")
16634 (defvar org-shiftdown-hook nil
16635 "Hook for functions attaching themselves to `S-down'.
16636 See `org-ctrl-c-ctrl-c-hook' for more information.")
16637 (defvar org-shiftdown-final-hook nil
16638 "Hook for functions attaching themselves to `S-down'.
16639 This one runs after all other options except shift-select have been excluded.
16640 See `org-ctrl-c-ctrl-c-hook' for more information.")
16641 (defvar org-shiftleft-hook nil
16642 "Hook for functions attaching themselves to `S-left'.
16643 See `org-ctrl-c-ctrl-c-hook' for more information.")
16644 (defvar org-shiftleft-final-hook nil
16645 "Hook for functions attaching themselves to `S-left'.
16646 This one runs after all other options except shift-select have been excluded.
16647 See `org-ctrl-c-ctrl-c-hook' for more information.")
16648 (defvar org-shiftright-hook nil
16649 "Hook for functions attaching themselves to `S-right'.
16650 See `org-ctrl-c-ctrl-c-hook' for more information.")
16651 (defvar org-shiftright-final-hook nil
16652 "Hook for functions attaching themselves to `S-right'.
16653 This one runs after all other options except shift-select have been excluded.
16654 See `org-ctrl-c-ctrl-c-hook' for more information.")
15894 16655
15895 (defun org-modifier-cursor-error () 16656 (defun org-modifier-cursor-error ()
15896 "Throw an error, a modified cursor command was applied in wrong context." 16657 "Throw an error, a modified cursor command was applied in wrong context."
15897 (error "This command is active in special context like tables, headlines or items")) 16658 (error "This command is active in special context like tables, headlines or items"))
15898 16659
15929 (interactive) 16690 (interactive)
15930 (cond 16691 (cond
15931 ((run-hook-with-args-until-success 'org-shiftmetaleft-hook)) 16692 ((run-hook-with-args-until-success 'org-shiftmetaleft-hook))
15932 ((org-at-table-p) (call-interactively 'org-table-delete-column)) 16693 ((org-at-table-p) (call-interactively 'org-table-delete-column))
15933 ((org-on-heading-p) (call-interactively 'org-promote-subtree)) 16694 ((org-on-heading-p) (call-interactively 'org-promote-subtree))
15934 ((org-at-item-p) (call-interactively 'org-outdent-item)) 16695 ((org-at-item-p) (call-interactively 'org-outdent-item-tree))
15935 (t (org-modifier-cursor-error)))) 16696 (t (org-modifier-cursor-error))))
15936 16697
15937 (defun org-shiftmetaright () 16698 (defun org-shiftmetaright ()
15938 "Demote subtree or insert table column. 16699 "Demote subtree or insert table column.
15939 Calls `org-demote-subtree', `org-indent-item', 16700 Calls `org-demote-subtree', `org-indent-item',
15942 (interactive) 16703 (interactive)
15943 (cond 16704 (cond
15944 ((run-hook-with-args-until-success 'org-shiftmetaright-hook)) 16705 ((run-hook-with-args-until-success 'org-shiftmetaright-hook))
15945 ((org-at-table-p) (call-interactively 'org-table-insert-column)) 16706 ((org-at-table-p) (call-interactively 'org-table-insert-column))
15946 ((org-on-heading-p) (call-interactively 'org-demote-subtree)) 16707 ((org-on-heading-p) (call-interactively 'org-demote-subtree))
15947 ((org-at-item-p) (call-interactively 'org-indent-item)) 16708 ((org-at-item-p) (call-interactively 'org-indent-item-tree))
15948 (t (org-modifier-cursor-error)))) 16709 (t (org-modifier-cursor-error))))
15949 16710
15950 (defun org-shiftmetaup (&optional arg) 16711 (defun org-shiftmetaup (&optional arg)
15951 "Move subtree up or kill table row. 16712 "Move subtree up or kill table row.
15952 Calls `org-move-subtree-up' or `org-table-kill-row' or 16713 Calls `org-move-subtree-up' or `org-table-kill-row' or
15970 ((run-hook-with-args-until-success 'org-shiftmetadown-hook)) 16731 ((run-hook-with-args-until-success 'org-shiftmetadown-hook))
15971 ((org-at-table-p) (call-interactively 'org-table-insert-row)) 16732 ((org-at-table-p) (call-interactively 'org-table-insert-row))
15972 ((org-on-heading-p) (call-interactively 'org-move-subtree-down)) 16733 ((org-on-heading-p) (call-interactively 'org-move-subtree-down))
15973 ((org-at-item-p) (call-interactively 'org-move-item-down)) 16734 ((org-at-item-p) (call-interactively 'org-move-item-down))
15974 (t (org-modifier-cursor-error)))) 16735 (t (org-modifier-cursor-error))))
16736
16737 (defsubst org-hidden-tree-error ()
16738 (error
16739 "Hidden subtree, open with TAB or use subtree command M-S-<left>/<right>"))
15975 16740
15976 (defun org-metaleft (&optional arg) 16741 (defun org-metaleft (&optional arg)
15977 "Promote heading or move table column to left. 16742 "Promote heading or move table column to left.
15978 Calls `org-do-promote' or `org-table-move-column', depending on context. 16743 Calls `org-do-promote' or `org-table-move-column', depending on context.
15979 With no specific context, calls the Emacs default `backward-word'. 16744 With no specific context, calls the Emacs default `backward-word'.
15985 ((or (org-on-heading-p) 16750 ((or (org-on-heading-p)
15986 (and (org-region-active-p) 16751 (and (org-region-active-p)
15987 (save-excursion 16752 (save-excursion
15988 (goto-char (region-beginning)) 16753 (goto-char (region-beginning))
15989 (org-on-heading-p)))) 16754 (org-on-heading-p))))
16755 (when (org-check-for-hidden 'headlines) (org-hidden-tree-error))
15990 (call-interactively 'org-do-promote)) 16756 (call-interactively 'org-do-promote))
15991 ((or (org-at-item-p) 16757 ((or (org-at-item-p)
15992 (and (org-region-active-p) 16758 (and (org-region-active-p)
15993 (save-excursion 16759 (save-excursion
15994 (goto-char (region-beginning)) 16760 (goto-char (region-beginning))
15995 (org-at-item-p)))) 16761 (org-at-item-p))))
16762 (when (org-check-for-hidden 'items) (org-hidden-tree-error))
15996 (call-interactively 'org-outdent-item)) 16763 (call-interactively 'org-outdent-item))
15997 (t (call-interactively 'backward-word)))) 16764 (t (call-interactively 'backward-word))))
15998 16765
15999 (defun org-metaright (&optional arg) 16766 (defun org-metaright (&optional arg)
16000 "Demote subtree or move table column to right. 16767 "Demote subtree or move table column to right.
16008 ((or (org-on-heading-p) 16775 ((or (org-on-heading-p)
16009 (and (org-region-active-p) 16776 (and (org-region-active-p)
16010 (save-excursion 16777 (save-excursion
16011 (goto-char (region-beginning)) 16778 (goto-char (region-beginning))
16012 (org-on-heading-p)))) 16779 (org-on-heading-p))))
16780 (when (org-check-for-hidden 'headlines) (org-hidden-tree-error))
16013 (call-interactively 'org-do-demote)) 16781 (call-interactively 'org-do-demote))
16014 ((or (org-at-item-p) 16782 ((or (org-at-item-p)
16015 (and (org-region-active-p) 16783 (and (org-region-active-p)
16016 (save-excursion 16784 (save-excursion
16017 (goto-char (region-beginning)) 16785 (goto-char (region-beginning))
16018 (org-at-item-p)))) 16786 (org-at-item-p))))
16787 (when (org-check-for-hidden 'items) (org-hidden-tree-error))
16019 (call-interactively 'org-indent-item)) 16788 (call-interactively 'org-indent-item))
16020 (t (call-interactively 'forward-word)))) 16789 (t (call-interactively 'forward-word))))
16790
16791 (defun org-check-for-hidden (what)
16792 "Check if there are hidden headlines/items in the current visual line.
16793 WHAT can be either `headlines' or `items'. If the current line is
16794 an outline or item heading and it has a folded subtree below it,
16795 this function returns t, nil otherwise."
16796 (let ((re (cond
16797 ((eq what 'headlines) (concat "^" org-outline-regexp))
16798 ((eq what 'items) (concat "^" (org-item-re t)))
16799 (t (error "This should not happen"))))
16800 beg end)
16801 (save-excursion
16802 (catch 'exit
16803 (unless (org-region-active-p)
16804 (setq beg (point-at-bol))
16805 (beginning-of-line 2)
16806 (while (and (not (eobp)) ;; this is like `next-line'
16807 (get-char-property (1- (point)) 'invisible))
16808 (beginning-of-line 2))
16809 (setq end (point))
16810 (goto-char beg)
16811 (goto-char (point-at-eol))
16812 (setq end (max end (point)))
16813 (while (re-search-forward re end t)
16814 (if (get-char-property (match-beginning 0) 'invisible)
16815 (throw 'exit t))))
16816 nil))))
16021 16817
16022 (defun org-metaup (&optional arg) 16818 (defun org-metaup (&optional arg)
16023 "Move subtree up or move table row up. 16819 "Move subtree up or move table row up.
16024 Calls `org-move-subtree-up' or `org-table-move-row' or 16820 Calls `org-move-subtree-up' or `org-table-move-row' or
16025 `org-move-item-up', depending on context. See the individual commands 16821 `org-move-item-up', depending on context. See the individual commands
16049 "Increase item in timestamp or increase priority of current headline. 16845 "Increase item in timestamp or increase priority of current headline.
16050 Calls `org-timestamp-up' or `org-priority-up', or `org-previous-item', 16846 Calls `org-timestamp-up' or `org-priority-up', or `org-previous-item',
16051 depending on context. See the individual commands for more information." 16847 depending on context. See the individual commands for more information."
16052 (interactive "P") 16848 (interactive "P")
16053 (cond 16849 (cond
16850 ((run-hook-with-args-until-success 'org-shiftup-hook))
16054 ((and org-support-shift-select (org-region-active-p)) 16851 ((and org-support-shift-select (org-region-active-p))
16055 (org-call-for-shift-select 'previous-line)) 16852 (org-call-for-shift-select 'previous-line))
16056 ((org-at-timestamp-p t) 16853 ((org-at-timestamp-p t)
16057 (call-interactively (if org-edit-timestamp-down-means-later 16854 (call-interactively (if org-edit-timestamp-down-means-later
16058 'org-timestamp-down 'org-timestamp-up))) 16855 'org-timestamp-down 'org-timestamp-up)))
16061 (org-on-heading-p)) 16858 (org-on-heading-p))
16062 (call-interactively 'org-priority-up)) 16859 (call-interactively 'org-priority-up))
16063 ((and (not org-support-shift-select) (org-at-item-p)) 16860 ((and (not org-support-shift-select) (org-at-item-p))
16064 (call-interactively 'org-previous-item)) 16861 (call-interactively 'org-previous-item))
16065 ((org-clocktable-try-shift 'up arg)) 16862 ((org-clocktable-try-shift 'up arg))
16863 ((run-hook-with-args-until-success 'org-shiftup-final-hook))
16066 (org-support-shift-select 16864 (org-support-shift-select
16067 (org-call-for-shift-select 'previous-line)) 16865 (org-call-for-shift-select 'previous-line))
16068 (t (org-shiftselect-error)))) 16866 (t (org-shiftselect-error))))
16069 16867
16070 (defun org-shiftdown (&optional arg) 16868 (defun org-shiftdown (&optional arg)
16071 "Decrease item in timestamp or decrease priority of current headline. 16869 "Decrease item in timestamp or decrease priority of current headline.
16072 Calls `org-timestamp-down' or `org-priority-down', or `org-next-item' 16870 Calls `org-timestamp-down' or `org-priority-down', or `org-next-item'
16073 depending on context. See the individual commands for more information." 16871 depending on context. See the individual commands for more information."
16074 (interactive "P") 16872 (interactive "P")
16075 (cond 16873 (cond
16874 ((run-hook-with-args-until-success 'org-shiftdown-hook))
16076 ((and org-support-shift-select (org-region-active-p)) 16875 ((and org-support-shift-select (org-region-active-p))
16077 (org-call-for-shift-select 'next-line)) 16876 (org-call-for-shift-select 'next-line))
16078 ((org-at-timestamp-p t) 16877 ((org-at-timestamp-p t)
16079 (call-interactively (if org-edit-timestamp-down-means-later 16878 (call-interactively (if org-edit-timestamp-down-means-later
16080 'org-timestamp-up 'org-timestamp-down))) 16879 'org-timestamp-up 'org-timestamp-down)))
16083 (org-on-heading-p)) 16882 (org-on-heading-p))
16084 (call-interactively 'org-priority-down)) 16883 (call-interactively 'org-priority-down))
16085 ((and (not org-support-shift-select) (org-at-item-p)) 16884 ((and (not org-support-shift-select) (org-at-item-p))
16086 (call-interactively 'org-next-item)) 16885 (call-interactively 'org-next-item))
16087 ((org-clocktable-try-shift 'down arg)) 16886 ((org-clocktable-try-shift 'down arg))
16887 ((run-hook-with-args-until-success 'org-shiftdown-final-hook))
16088 (org-support-shift-select 16888 (org-support-shift-select
16089 (org-call-for-shift-select 'next-line)) 16889 (org-call-for-shift-select 'next-line))
16090 (t (org-shiftselect-error)))) 16890 (t (org-shiftselect-error))))
16091 16891
16092 (defun org-shiftright (&optional arg) 16892 (defun org-shiftright (&optional arg)
16098 - on an item, switch entire list to the next bullet type 16898 - on an item, switch entire list to the next bullet type
16099 - on a property line, switch to the next allowed value 16899 - on a property line, switch to the next allowed value
16100 - on a clocktable definition line, move time block into the future" 16900 - on a clocktable definition line, move time block into the future"
16101 (interactive "P") 16901 (interactive "P")
16102 (cond 16902 (cond
16903 ((run-hook-with-args-until-success 'org-shiftright-hook))
16103 ((and org-support-shift-select (org-region-active-p)) 16904 ((and org-support-shift-select (org-region-active-p))
16104 (org-call-for-shift-select 'forward-char)) 16905 (org-call-for-shift-select 'forward-char))
16105 ((org-at-timestamp-p t) (call-interactively 'org-timestamp-up-day)) 16906 ((org-at-timestamp-p t) (call-interactively 'org-timestamp-up-day))
16106 ((and (not (eq org-support-shift-select 'always)) 16907 ((and (not (eq org-support-shift-select 'always))
16107 (org-on-heading-p)) 16908 (org-on-heading-p))
16117 (org-call-with-arg 'org-cycle-list-bullet nil)) 16918 (org-call-with-arg 'org-cycle-list-bullet nil))
16118 ((and (not (eq org-support-shift-select 'always)) 16919 ((and (not (eq org-support-shift-select 'always))
16119 (org-at-property-p)) 16920 (org-at-property-p))
16120 (call-interactively 'org-property-next-allowed-value)) 16921 (call-interactively 'org-property-next-allowed-value))
16121 ((org-clocktable-try-shift 'right arg)) 16922 ((org-clocktable-try-shift 'right arg))
16923 ((run-hook-with-args-until-success 'org-shiftright-final-hook))
16122 (org-support-shift-select 16924 (org-support-shift-select
16123 (org-call-for-shift-select 'forward-char)) 16925 (org-call-for-shift-select 'forward-char))
16124 (t (org-shiftselect-error)))) 16926 (t (org-shiftselect-error))))
16125 16927
16126 (defun org-shiftleft (&optional arg) 16928 (defun org-shiftleft (&optional arg)
16132 - on an item, switch entire list to the previous bullet type 16934 - on an item, switch entire list to the previous bullet type
16133 - on a property line, switch to the previous allowed value 16935 - on a property line, switch to the previous allowed value
16134 - on a clocktable definition line, move time block into the past" 16936 - on a clocktable definition line, move time block into the past"
16135 (interactive "P") 16937 (interactive "P")
16136 (cond 16938 (cond
16939 ((run-hook-with-args-until-success 'org-shiftleft-hook))
16137 ((and org-support-shift-select (org-region-active-p)) 16940 ((and org-support-shift-select (org-region-active-p))
16138 (org-call-for-shift-select 'backward-char)) 16941 (org-call-for-shift-select 'backward-char))
16139 ((org-at-timestamp-p t) (call-interactively 'org-timestamp-down-day)) 16942 ((org-at-timestamp-p t) (call-interactively 'org-timestamp-down-day))
16140 ((and (not (eq org-support-shift-select 'always)) 16943 ((and (not (eq org-support-shift-select 'always))
16141 (org-on-heading-p)) 16944 (org-on-heading-p))
16151 (org-call-with-arg 'org-cycle-list-bullet 'previous)) 16954 (org-call-with-arg 'org-cycle-list-bullet 'previous))
16152 ((and (not (eq org-support-shift-select 'always)) 16955 ((and (not (eq org-support-shift-select 'always))
16153 (org-at-property-p)) 16956 (org-at-property-p))
16154 (call-interactively 'org-property-previous-allowed-value)) 16957 (call-interactively 'org-property-previous-allowed-value))
16155 ((org-clocktable-try-shift 'left arg)) 16958 ((org-clocktable-try-shift 'left arg))
16959 ((run-hook-with-args-until-success 'org-shiftleft-final-hook))
16156 (org-support-shift-select 16960 (org-support-shift-select
16157 (org-call-for-shift-select 'backward-char)) 16961 (org-call-for-shift-select 'backward-char))
16158 (t (org-shiftselect-error)))) 16962 (t (org-shiftselect-error))))
16159 16963
16160 (defun org-shiftcontrolright () 16964 (defun org-shiftcontrolright ()
16213 (interactive "P") 17017 (interactive "P")
16214 (if (org-at-table-p) 17018 (if (org-at-table-p)
16215 (org-table-paste-rectangle) 17019 (org-table-paste-rectangle)
16216 (org-paste-subtree arg))) 17020 (org-paste-subtree arg)))
16217 17021
16218 (defun org-edit-special () 17022 (defun org-edit-special (&optional arg)
16219 "Call a special editor for the stuff at point. 17023 "Call a special editor for the stuff at point.
16220 When at a table, call the formula editor with `org-table-edit-formulas'. 17024 When at a table, call the formula editor with `org-table-edit-formulas'.
16221 When at the first line of an src example, call `org-edit-src-code'. 17025 When at the first line of an src example, call `org-edit-src-code'.
16222 When in an #+include line, visit the include file. Otherwise call 17026 When in an #+include line, visit the include file. Otherwise call
16223 `ffap' to visit the file at point." 17027 `ffap' to visit the file at point."
16224 (interactive) 17028 (interactive)
16225 (cond 17029 ;; possibly prep session before editing source
16226 ((org-at-table.el-p) 17030 (when arg
16227 (org-edit-src-code)) 17031 (let* ((info (org-babel-get-src-block-info))
16228 ((org-at-table-p) 17032 (lang (nth 0 info))
16229 (call-interactively 'org-table-edit-formulas)) 17033 (params (nth 2 info))
17034 (session (cdr (assoc :session params))))
17035 (when (and info session) ;; we are in a source-code block with a session
17036 (funcall
17037 (intern (concat "org-babel-prep-session:" lang)) session params))))
17038 (cond ;; proceed with `org-edit-special'
16230 ((save-excursion 17039 ((save-excursion
16231 (beginning-of-line 1) 17040 (beginning-of-line 1)
16232 (looking-at "\\(?:#\\+\\(?:setupfile\\|include\\):?[ \t]+\"?\\|[ \t]*<include\\>.*?file=\"\\)\\([^\"\n>]+\\)")) 17041 (looking-at "\\(?:#\\+\\(?:setupfile\\|include\\):?[ \t]+\"?\\|[ \t]*<include\\>.*?file=\"\\)\\([^\"\n>]+\\)"))
16233 (find-file (org-trim (match-string 1)))) 17042 (find-file (org-trim (match-string 1))))
16234 ((org-edit-src-code)) 17043 ((org-edit-src-code))
16235 ((org-edit-fixed-width-region)) 17044 ((org-edit-fixed-width-region))
17045 ((org-at-table.el-p)
17046 (org-edit-src-code))
17047 ((org-at-table-p)
17048 (call-interactively 'org-table-edit-formulas))
16236 (t (call-interactively 'ffap)))) 17049 (t (call-interactively 'ffap))))
16237 17050
16238 17051
16239 (defun org-ctrl-c-ctrl-c (&optional arg) 17052 (defun org-ctrl-c-ctrl-c (&optional arg)
16240 "Set tags in headline, or update according to changed information at point. 17053 "Set tags in headline, or update according to changed information at point.
16274 links in this buffer. 17087 links in this buffer.
16275 17088
16276 - If the cursor is on a numbered item in a plain list, renumber the 17089 - If the cursor is on a numbered item in a plain list, renumber the
16277 ordered list. 17090 ordered list.
16278 17091
16279 - If the cursor is on a checkbox, toggle it." 17092 - If the cursor is on a checkbox, toggle it.
17093
17094 - If the cursor is on a code block, evaluate it. The variable
17095 `org-confirm-babel-evaluate' can be used to control prompting
17096 before code block evaluation, by default every code block
17097 evaluation requires confirmation. Code block evaluation can be
17098 inhibited by setting `org-babel-no-eval-on-ctrl-c-ctrl-c'."
16280 (interactive "P") 17099 (interactive "P")
16281 (let ((org-enable-table-editor t)) 17100 (let ((org-enable-table-editor t))
16282 (cond 17101 (cond
16283 ((or (and (boundp 'org-clock-overlays) org-clock-overlays) 17102 ((or (and (boundp 'org-clock-overlays) org-clock-overlays)
16284 org-occur-highlights 17103 org-occur-highlights
16309 (call-interactively 'org-table-align)) 17128 (call-interactively 'org-table-align))
16310 ((or (org-footnote-at-reference-p) 17129 ((or (org-footnote-at-reference-p)
16311 (org-footnote-at-definition-p)) 17130 (org-footnote-at-definition-p))
16312 (call-interactively 'org-footnote-action)) 17131 (call-interactively 'org-footnote-action))
16313 ((org-at-item-checkbox-p) 17132 ((org-at-item-checkbox-p)
16314 (call-interactively 'org-toggle-checkbox)) 17133 (call-interactively 'org-toggle-checkbox)
17134 (org-list-send-list 'maybe))
16315 ((org-at-item-p) 17135 ((org-at-item-p)
16316 (if arg 17136 (if arg
16317 (call-interactively 'org-toggle-checkbox) 17137 (call-interactively 'org-toggle-checkbox)
16318 (call-interactively 'org-maybe-renumber-ordered-list))) 17138 (call-interactively 'org-maybe-renumber-ordered-list))
17139 (org-list-send-list 'maybe))
16319 ((save-excursion (beginning-of-line 1) (looking-at org-dblock-start-re)) 17140 ((save-excursion (beginning-of-line 1) (looking-at org-dblock-start-re))
16320 ;; Dynamic block 17141 ;; Dynamic block
16321 (beginning-of-line 1) 17142 (beginning-of-line 1)
16322 (save-excursion (org-update-dblock))) 17143 (save-excursion (org-update-dblock)))
16323 ((save-excursion 17144 ((save-excursion
16348 17169
16349 (defun org-kill-note-or-show-branches () 17170 (defun org-kill-note-or-show-branches ()
16350 "If this is a Note buffer, abort storing the note. Else call `show-branches'." 17171 "If this is a Note buffer, abort storing the note. Else call `show-branches'."
16351 (interactive) 17172 (interactive)
16352 (if (not org-finish-function) 17173 (if (not org-finish-function)
16353 (call-interactively 'show-branches) 17174 (progn
17175 (hide-subtree)
17176 (call-interactively 'show-branches))
16354 (let ((org-note-abort t)) 17177 (let ((org-note-abort t))
16355 (funcall org-finish-function)))) 17178 (funcall org-finish-function))))
16356 17179
16357 (defun org-return (&optional indent) 17180 (defun org-return (&optional indent)
16358 "Goto next table row or insert a newline. 17181 "Goto next table row or insert a newline.
16643 "--" 17466 "--"
16644 ["Next link" org-next-link t] 17467 ["Next link" org-next-link t]
16645 ["Previous link" org-previous-link t] 17468 ["Previous link" org-previous-link t]
16646 "--" 17469 "--"
16647 ["Descriptive Links" 17470 ["Descriptive Links"
16648 (progn (org-add-to-invisibility-spec '(org-link)) (org-restart-font-lock)) 17471 (progn (add-to-invisibility-spec '(org-link)) (org-restart-font-lock))
16649 :style radio 17472 :style radio
16650 :selected (member '(org-link) buffer-invisibility-spec)] 17473 :selected (member '(org-link) buffer-invisibility-spec)]
16651 ["Literal Links" 17474 ["Literal Links"
16652 (progn 17475 (progn
16653 (org-remove-from-invisibility-spec '(org-link)) (org-restart-font-lock)) 17476 (org-remove-from-invisibility-spec '(org-link)) (org-restart-font-lock))
16660 ["Next keyword" org-shiftright (org-on-heading-p)] 17483 ["Next keyword" org-shiftright (org-on-heading-p)]
16661 ["Previous keyword" org-shiftleft (org-on-heading-p)] 17484 ["Previous keyword" org-shiftleft (org-on-heading-p)]
16662 ["Complete Keyword" org-complete (assq :todo-keyword (org-context))] 17485 ["Complete Keyword" org-complete (assq :todo-keyword (org-context))]
16663 ["Next keyword set" org-shiftcontrolright (and (> (length org-todo-sets) 1) (org-on-heading-p))] 17486 ["Next keyword set" org-shiftcontrolright (and (> (length org-todo-sets) 1) (org-on-heading-p))]
16664 ["Previous keyword set" org-shiftcontrolright (and (> (length org-todo-sets) 1) (org-on-heading-p))]) 17487 ["Previous keyword set" org-shiftcontrolright (and (> (length org-todo-sets) 1) (org-on-heading-p))])
16665 ["Show TODO Tree" org-show-todo-tree t] 17488 ["Show TODO Tree" org-show-todo-tree :active t :keys "C-c / t"]
16666 ["Global TODO list" org-todo-list t] 17489 ["Global TODO list" org-todo-list :active t :keys "C-c a t"]
16667 "--" 17490 "--"
16668 ["Enforce dependencies" (customize-variable 'org-enforce-todo-dependencies) 17491 ["Enforce dependencies" (customize-variable 'org-enforce-todo-dependencies)
16669 :selected org-enforce-todo-dependencies :style toggle :active t] 17492 :selected org-enforce-todo-dependencies :style toggle :active t]
16670 "Settings for tree at point" 17493 "Settings for tree at point"
16671 ["Do Children sequentially" org-toggle-ordered-property :style radio 17494 ["Do Children sequentially" org-toggle-ordered-property :style radio
16757 (not org-export-with-LaTeX-fragments)) 17580 (not org-export-with-LaTeX-fragments))
16758 (require 'org-exp)) 17581 (require 'org-exp))
16759 :style toggle :selected (and (boundp 'org-export-with-LaTeX-fragments) 17582 :style toggle :selected (and (boundp 'org-export-with-LaTeX-fragments)
16760 org-export-with-LaTeX-fragments)] 17583 org-export-with-LaTeX-fragments)]
16761 "--" 17584 "--"
16762 ["Template for BEAMER" org-beamer-settings-template t]) 17585 ["Template for BEAMER" org-insert-beamer-options-template t])
16763 "--" 17586 "--"
16764 ("MobileOrg" 17587 ("MobileOrg"
16765 ["Push Files and Views" org-mobile-push t] 17588 ["Push Files and Views" org-mobile-push t]
16766 ["Get Captured and Flagged" org-mobile-pull t] 17589 ["Get Captured and Flagged" org-mobile-pull t]
16767 ["Find FLAGGED Tasks" (org-agenda nil "?") :active t :keys "C-c a ?"] 17590 ["Find FLAGGED Tasks" (org-agenda nil "?") :active t :keys "C-c a ?"]
16890 (let* ((file-re "^\\(org\\|orgtbl\\)\\(\\.el\\|-.*\\.el\\)") 17713 (let* ((file-re "^\\(org\\|orgtbl\\)\\(\\.el\\|-.*\\.el\\)")
16891 (dir-org (file-name-directory (org-find-library-name "org"))) 17714 (dir-org (file-name-directory (org-find-library-name "org")))
16892 (dir-org-contrib (ignore-errors 17715 (dir-org-contrib (ignore-errors
16893 (file-name-directory 17716 (file-name-directory
16894 (org-find-library-name "org-contribdir")))) 17717 (org-find-library-name "org-contribdir"))))
17718 (babel-files
17719 (mapcar (lambda (el) (concat "ob" (when el (format "-%s" el)) ".el"))
17720 (append (list nil "comint" "eval" "exp" "keys"
17721 "lob" "ref" "table" "tangle")
17722 (delq nil
17723 (mapcar
17724 (lambda (lang)
17725 (when (cdr lang) (symbol-name (car lang))))
17726 org-babel-load-languages)))))
16895 (files 17727 (files
16896 (append (directory-files dir-org t file-re) 17728 (append (directory-files dir-org t file-re)
17729 babel-files
16897 (and dir-org-contrib 17730 (and dir-org-contrib
16898 (directory-files dir-org-contrib t file-re)))) 17731 (directory-files dir-org-contrib t file-re))))
16899 (remove-re (concat (if (featurep 'xemacs) 17732 (remove-re (concat (if (featurep 'xemacs)
16900 "org-colview" "org-colview-xemacs") 17733 "org-colview" "org-colview-xemacs")
16901 "\\'"))) 17734 "\\'")))
16958 17791
16959 (defun org-display-warning (message) ;; Copied from Emacs-Muse 17792 (defun org-display-warning (message) ;; Copied from Emacs-Muse
16960 "Display the given MESSAGE as a warning." 17793 "Display the given MESSAGE as a warning."
16961 (if (fboundp 'display-warning) 17794 (if (fboundp 'display-warning)
16962 (display-warning 'org message 17795 (display-warning 'org message
16963 (if (featurep 'xemacs) 17796 (if (featurep 'xemacs) 'warning :warning))
16964 'warning
16965 :warning))
16966 (let ((buf (get-buffer-create "*Org warnings*"))) 17797 (let ((buf (get-buffer-create "*Org warnings*")))
16967 (with-current-buffer buf 17798 (with-current-buffer buf
16968 (goto-char (point-max)) 17799 (goto-char (point-max))
16969 (insert "Warning (Org): " message) 17800 (insert "Warning (Org): " message)
16970 (unless (bolp) 17801 (unless (bolp)
16973 (sit-for 0)))) 17804 (sit-for 0))))
16974 17805
16975 (defun org-in-commented-line () 17806 (defun org-in-commented-line ()
16976 "Is point in a line starting with `#'?" 17807 "Is point in a line starting with `#'?"
16977 (equal (char-after (point-at-bol)) ?#)) 17808 (equal (char-after (point-at-bol)) ?#))
17809
17810 (defun org-in-indented-comment-line ()
17811 "Is point in a line starting with `#' after some white space?"
17812 (save-excursion
17813 (save-match-data
17814 (goto-char (point-at-bol))
17815 (looking-at "[ \t]*#"))))
16978 17816
16979 (defun org-in-verbatim-emphasis () 17817 (defun org-in-verbatim-emphasis ()
16980 (save-match-data 17818 (save-match-data
16981 (and (org-in-regexp org-emph-re 2) (member (match-string 3) '("=" "~"))))) 17819 (and (org-in-regexp org-emph-re 2) (member (match-string 3) '("=" "~")))))
16982 17820
17281 (goto-char p)) 18119 (goto-char p))
17282 ((setq o (car (delq nil 18120 ((setq o (car (delq nil
17283 (mapcar 18121 (mapcar
17284 (lambda (x) 18122 (lambda (x)
17285 (if (memq x org-latex-fragment-image-overlays) x)) 18123 (if (memq x org-latex-fragment-image-overlays) x))
17286 (org-overlays-at (point)))))) 18124 (overlays-at (point))))))
17287 (push (list :latex-fragment 18125 (push (list :latex-fragment
17288 (org-overlay-start o) (org-overlay-end o)) clist) 18126 (overlay-start o) (overlay-end o)) clist)
17289 (push (list :latex-preview 18127 (push (list :latex-preview
17290 (org-overlay-start o) (org-overlay-end o)) clist)) 18128 (overlay-start o) (overlay-end o)) clist))
17291 ((org-inside-LaTeX-fragment-p) 18129 ((org-inside-LaTeX-fragment-p)
17292 ;; FIXME: positions wrong. 18130 ;; FIXME: positions wrong.
17293 (push (list :latex-fragment (point) (point)) clist))) 18131 (push (list :latex-fragment (point) (point)) clist)))
17294 18132
17295 (setq clist (nreverse (delq nil clist))) 18133 (setq clist (nreverse (delq nil clist)))
17324 (>= (match-end 0) pos)) 18162 (>= (match-end 0) pos))
17325 (throw 'exit t))) 18163 (throw 'exit t)))
17326 nil)))) 18164 nil))))
17327 18165
17328 (defun org-in-regexps-block-p (start-re end-re) 18166 (defun org-in-regexps-block-p (start-re end-re)
17329 "Returns t if the current point is between matches of START-RE and END-RE. 18167 "Return t if the current point is between matches of START-RE and END-RE.
17330 This will also return to if point is on one of the two matches." 18168 This will also return to if point is on one of the two matches."
17331 (interactive) 18169 (interactive)
17332 (let ((p (point))) 18170 (let ((p (point)))
17333 (save-excursion 18171 (save-excursion
17334 (and (or (org-at-regexp-p start-re) 18172 (and (or (org-at-regexp-p start-re)
17401 "Remove all elements in ELTS from LIST." 18239 "Remove all elements in ELTS from LIST."
17402 (while elts 18240 (while elts
17403 (setq list (delete (pop elts) list))) 18241 (setq list (delete (pop elts) list)))
17404 list) 18242 list)
17405 18243
18244 (defun org-count (cl-item cl-seq)
18245 "Count the number of occurrences of ITEM in SEQ.
18246 Taken from `count' in cl-seq.el with all keyword arguments removed."
18247 (let ((cl-end (length cl-seq)) (cl-start 0) (cl-count 0) cl-x)
18248 (when (consp cl-seq) (setq cl-seq (nthcdr cl-start cl-seq)))
18249 (while (< cl-start cl-end)
18250 (setq cl-x (if (consp cl-seq) (pop cl-seq) (aref cl-seq cl-start)))
18251 (if (equal cl-item cl-x) (setq cl-count (1+ cl-count)))
18252 (setq cl-start (1+ cl-start)))
18253 cl-count))
18254
18255 (defun org-remove-if (predicate seq)
18256 "Remove everything from SEQ that fulfills PREDICATE."
18257 (let (res e)
18258 (while seq
18259 (setq e (pop seq))
18260 (if (not (funcall predicate e)) (push e res)))
18261 (nreverse res)))
18262
18263 (defun org-remove-if-not (predicate seq)
18264 "Remove everything from SEQ that does not fulfill PREDICATE."
18265 (let (res e)
18266 (while seq
18267 (setq e (pop seq))
18268 (if (funcall predicate e) (push e res)))
18269 (nreverse res)))
18270
17406 (defun org-back-over-empty-lines () 18271 (defun org-back-over-empty-lines ()
17407 "Move backwards over whitespace, to the beginning of the first empty line. 18272 "Move backwards over whitespace, to the beginning of the first empty line.
17408 Returns the number of empty lines passed." 18273 Returns the number of empty lines passed."
17409 (let ((pos (point))) 18274 (let ((pos (point)))
17410 (skip-chars-backward " \t\n\r") 18275 (skip-chars-backward " \t\n\r")
17416 (skip-chars-forward " \t\n\r")) 18281 (skip-chars-forward " \t\n\r"))
17417 18282
17418 (defun org-point-in-group (point group &optional context) 18283 (defun org-point-in-group (point group &optional context)
17419 "Check if POINT is in match-group GROUP. 18284 "Check if POINT is in match-group GROUP.
17420 If CONTEXT is non-nil, return a list with CONTEXT and the boundaries of the 18285 If CONTEXT is non-nil, return a list with CONTEXT and the boundaries of the
17421 match. If the match group does ot exist or point is not inside it, 18286 match. If the match group does not exist or point is not inside it,
17422 return nil." 18287 return nil."
17423 (and (match-beginning group) 18288 (and (match-beginning group)
17424 (>= point (match-beginning group)) 18289 (>= point (match-beginning group))
17425 (<= point (match-end group)) 18290 (<= point (match-end group))
17426 (if context 18291 (if context
17427 (list context (match-beginning group) (match-end group)) 18292 (list context (match-beginning group) (match-end group))
17428 t))) 18293 t)))
17429 18294
17430 (defun org-switch-to-buffer-other-window (&rest args) 18295 (defun org-switch-to-buffer-other-window (&rest args)
17431 "Switch to buffer in a second window on the current frame. 18296 "Switch to buffer in a second window on the current frame.
17432 In particular, do not allow pop-up frames." 18297 In particular, do not allow pop-up frames.
18298 Returns the newly created buffer."
17433 (let (pop-up-frames special-display-buffer-names special-display-regexps 18299 (let (pop-up-frames special-display-buffer-names special-display-regexps
17434 special-display-function) 18300 special-display-function)
17435 (apply 'switch-to-buffer-other-window args))) 18301 (apply 'switch-to-buffer-other-window args)))
17436 18302
17437 (defun org-combine-plists (&rest plists) 18303 (defun org-combine-plists (&rest plists)
17478 "Replace %-escapes in STRING with values in TABLE. 18344 "Replace %-escapes in STRING with values in TABLE.
17479 TABLE is an association list with keys like \"%a\" and string values. 18345 TABLE is an association list with keys like \"%a\" and string values.
17480 The sequences in STRING may contain normal field width and padding information, 18346 The sequences in STRING may contain normal field width and padding information,
17481 for example \"%-5s\". Replacements happen in the sequence given by TABLE, 18347 for example \"%-5s\". Replacements happen in the sequence given by TABLE,
17482 so values can contain further %-escapes if they are define later in TABLE." 18348 so values can contain further %-escapes if they are define later in TABLE."
17483 (let ((case-fold-search nil) 18349 (let ((tbl (copy-alist table))
17484 e re rpl) 18350 (case-fold-search nil)
17485 (while (setq e (pop table)) 18351 (pchg 0)
18352 e re rpl)
18353 (while (setq e (pop tbl))
17486 (setq re (concat "%-?[0-9.]*" (substring (car e) 1))) 18354 (setq re (concat "%-?[0-9.]*" (substring (car e) 1)))
18355 (when (and (cdr e) (string-match re (cdr e)))
18356 (let ((sref (substring (cdr e) (match-beginning 0) (match-end 0)))
18357 (safe "SREF"))
18358 (add-text-properties 0 3 (list 'sref sref) safe)
18359 (setcdr e (replace-match safe t t (cdr e)))))
17487 (while (string-match re string) 18360 (while (string-match re string)
17488 (setq rpl (format (concat (substring (match-string 0 string) 0 -1) "s") 18361 (setq rpl (format (concat (substring (match-string 0 string) 0 -1) "s")
17489 (cdr e))) 18362 (cdr e)))
17490 (setq string (replace-match rpl t t string)))) 18363 (setq string (replace-match rpl t t string))))
18364 (while (setq pchg (next-property-change pchg string))
18365 (let ((sref (get-text-property pchg 'sref string)))
18366 (when (and sref (string-match "SREF" string pchg))
18367 (setq string (replace-match sref t t string)))))
17491 string)) 18368 string))
17492
17493 18369
17494 (defun org-sublist (list start end) 18370 (defun org-sublist (list start end)
17495 "Return a section of LIST, from START to END. 18371 "Return a section of LIST, from START to END.
17496 Counting starts at 1." 18372 Counting starts at 1."
17497 (let (rtn (c start)) 18373 (let (rtn (c start))
17683 ;; and fixed-width regions are not wrapped. That function will pass 18559 ;; and fixed-width regions are not wrapped. That function will pass
17684 ;; through to `fill-paragraph' when appropriate. 18560 ;; through to `fill-paragraph' when appropriate.
17685 (org-set-local 'fill-paragraph-function 'org-fill-paragraph) 18561 (org-set-local 'fill-paragraph-function 'org-fill-paragraph)
17686 ;; Adaptive filling: To get full control, first make sure that 18562 ;; Adaptive filling: To get full control, first make sure that
17687 ;; `adaptive-fill-regexp' never matches. Then install our own matcher. 18563 ;; `adaptive-fill-regexp' never matches. Then install our own matcher.
17688 (unless (local-variable-p 'adaptive-fill-regexp) 18564 (unless (local-variable-p 'adaptive-fill-regexp (current-buffer))
17689 (org-set-local 'org-adaptive-fill-regexp-backup 18565 (org-set-local 'org-adaptive-fill-regexp-backup
17690 adaptive-fill-regexp)) 18566 adaptive-fill-regexp))
17691 (org-set-local 'adaptive-fill-regexp "\000") 18567 (org-set-local 'adaptive-fill-regexp "\000")
17692 (org-set-local 'adaptive-fill-function 18568 (org-set-local 'adaptive-fill-function
17693 'org-adaptive-fill-function) 18569 'org-adaptive-fill-function)
17834 (if (and arg (fboundp 'move-beginning-of-line)) 18710 (if (and arg (fboundp 'move-beginning-of-line))
17835 (call-interactively 'move-beginning-of-line) 18711 (call-interactively 'move-beginning-of-line)
17836 (if (bobp) 18712 (if (bobp)
17837 nil 18713 nil
17838 (backward-char 1) 18714 (backward-char 1)
17839 (if (org-invisible-p) 18715 (if (org-truely-invisible-p)
17840 (while (and (not (bobp)) (org-invisible-p)) 18716 (while (and (not (bobp)) (org-truely-invisible-p))
17841 (backward-char 1) 18717 (backward-char 1)
17842 (beginning-of-line 1)) 18718 (beginning-of-line 1))
17843 (forward-char 1)))) 18719 (forward-char 1))))
17844 (when special 18720 (when special
17845 (cond 18721 (cond
17931 (interactive "P") 18807 (interactive "P")
17932 (cond 18808 (cond
17933 ((or (not org-special-ctrl-k) 18809 ((or (not org-special-ctrl-k)
17934 (bolp) 18810 (bolp)
17935 (not (org-on-heading-p))) 18811 (not (org-on-heading-p)))
18812 (if (and (get-char-property (min (point-max) (point-at-eol)) 'invisible)
18813 org-ctrl-k-protect-subtree)
18814 (if (or (eq org-ctrl-k-protect-subtree 'error)
18815 (not (y-or-n-p "Kill hidden subtree along with headline? ")))
18816 (error "C-k aborted - would kill hidden subtree")))
17936 (call-interactively 'kill-line)) 18817 (call-interactively 'kill-line))
17937 ((looking-at (org-re ".*?\\S-\\([ \t]+\\(:[[:alnum:]_@:]+:\\)\\)[ \t]*$")) 18818 ((looking-at (org-re ".*?\\S-\\([ \t]+\\(:[[:alnum:]_@:]+:\\)\\)[ \t]*$"))
17938 (kill-region (point) (match-beginning 1)) 18819 (kill-region (point) (match-beginning 1))
17939 (org-set-tags nil t)) 18820 (org-set-tags nil t))
17940 (t (kill-region (point) (point-at-eol))))) 18821 (t (kill-region (point) (point-at-eol)))))
17958 fit into the local outline tree structure, which means that the level 18839 fit into the local outline tree structure, which means that the level
17959 will be adjusted so that it becomes the smaller one of the two 18840 will be adjusted so that it becomes the smaller one of the two
17960 *visible* surrounding headings. 18841 *visible* surrounding headings.
17961 18842
17962 Any prefix to this command will cause `yank' to be called directly with 18843 Any prefix to this command will cause `yank' to be called directly with
17963 no special treatment. In particular, a simple `C-u' prefix will just 18844 no special treatment. In particular, a simple \\[universal-argument] prefix \
18845 will just
17964 plainly yank the text as it is. 18846 plainly yank the text as it is.
17965 18847
17966 \[1] The test checks if the first non-white line is a heading 18848 \[1] The test checks if the first non-white line is a heading
17967 and if there are no other headings with fewer stars." 18849 and if there are no other headings with fewer stars."
17968 (interactive "P") 18850 (interactive "P")
18048 ;; Early versions of noutline don't have `outline-invisible-p'. 18930 ;; Early versions of noutline don't have `outline-invisible-p'.
18049 (if (fboundp 'outline-invisible-p) 18931 (if (fboundp 'outline-invisible-p)
18050 (outline-invisible-p) 18932 (outline-invisible-p)
18051 (get-char-property (point) 'invisible))) 18933 (get-char-property (point) 'invisible)))
18052 18934
18935 (defun org-truely-invisible-p ()
18936 "Check if point is at a character currently not visible.
18937 This version does not only check the character property, but also
18938 `visible-mode'."
18939 ;; Early versions of noutline don't have `outline-invisible-p'.
18940 (if (org-bound-and-true-p visible-mode)
18941 nil
18942 (if (fboundp 'outline-invisible-p)
18943 (outline-invisible-p)
18944 (get-char-property (point) 'invisible))))
18945
18053 (defun org-invisible-p2 () 18946 (defun org-invisible-p2 ()
18054 "Check if point is at a character currently not visible." 18947 "Check if point is at a character currently not visible."
18055 (save-excursion 18948 (save-excursion
18056 (if (and (eolp) (not (bobp))) (backward-char 1)) 18949 (if (and (eolp) (not (bobp))) (backward-char 1))
18057 ;; Early versions of noutline don't have `outline-invisible-p'. 18950 ;; Early versions of noutline don't have `outline-invisible-p'.
18063 "Call `outline-back-to-heading', but provide a better error message." 18956 "Call `outline-back-to-heading', but provide a better error message."
18064 (condition-case nil 18957 (condition-case nil
18065 (outline-back-to-heading invisible-ok) 18958 (outline-back-to-heading invisible-ok)
18066 (error (error "Before first headline at position %d in buffer %s" 18959 (error (error "Before first headline at position %d in buffer %s"
18067 (point) (current-buffer))))) 18960 (point) (current-buffer)))))
18961
18962 (defun org-beginning-of-defun ()
18963 "Go to the beginning of the subtree, i.e. back to the heading."
18964 (org-back-to-heading))
18965 (defun org-end-of-defun ()
18966 "Go to the end of the subtree."
18967 (org-end-of-subtree nil t))
18068 18968
18069 (defun org-before-first-heading-p () 18969 (defun org-before-first-heading-p ()
18070 "Before first heading?" 18970 "Before first heading?"
18071 (save-excursion 18971 (save-excursion
18072 (null (re-search-backward "^\\*+ " nil t)))) 18972 (null (re-search-backward "^\\*+ " nil t))))
18408 nil t link) 19308 nil t link)
18409 link))) 19309 link)))
18410 19310
18411 ;; Speedbar support 19311 ;; Speedbar support
18412 19312
18413 (defvar org-speedbar-restriction-lock-overlay (org-make-overlay 1 1) 19313 (defvar org-speedbar-restriction-lock-overlay (make-overlay 1 1)
18414 "Overlay marking the agenda restriction line in speedbar.") 19314 "Overlay marking the agenda restriction line in speedbar.")
18415 (org-overlay-put org-speedbar-restriction-lock-overlay 19315 (overlay-put org-speedbar-restriction-lock-overlay
18416 'face 'org-agenda-restriction-lock) 19316 'face 'org-agenda-restriction-lock)
18417 (org-overlay-put org-speedbar-restriction-lock-overlay 19317 (overlay-put org-speedbar-restriction-lock-overlay
18418 'help-echo "Agendas are currently limited to this item.") 19318 'help-echo "Agendas are currently limited to this item.")
18419 (org-detach-overlay org-speedbar-restriction-lock-overlay) 19319 (org-detach-overlay org-speedbar-restriction-lock-overlay)
18420 19320
18421 (defun org-speedbar-set-agenda-restriction () 19321 (defun org-speedbar-set-agenda-restriction ()
18422 "Restrict future agenda commands to the location at point in speedbar. 19322 "Restrict future agenda commands to the location at point in speedbar.
18445 (expand-file-name txt))) 19345 (expand-file-name txt)))
18446 (unless (org-mode-p) 19346 (unless (org-mode-p)
18447 (error "Cannot restrict to non-Org-mode file")) 19347 (error "Cannot restrict to non-Org-mode file"))
18448 (org-agenda-set-restriction-lock 'file))) 19348 (org-agenda-set-restriction-lock 'file)))
18449 (t (error "Don't know how to restrict Org-mode's agenda"))) 19349 (t (error "Don't know how to restrict Org-mode's agenda")))
18450 (org-move-overlay org-speedbar-restriction-lock-overlay 19350 (move-overlay org-speedbar-restriction-lock-overlay
18451 (point-at-bol) (point-at-eol)) 19351 (point-at-bol) (point-at-eol))
18452 (setq current-prefix-arg nil) 19352 (setq current-prefix-arg nil)
18453 (org-agenda-maybe-redo))) 19353 (org-agenda-maybe-redo)))
18454 19354
18455 (eval-after-load "speedbar" 19355 (eval-after-load "speedbar"
18456 '(progn 19356 '(progn
18459 (define-key speedbar-file-key-map "\C-c\C-x<" 'org-speedbar-set-agenda-restriction) 19359 (define-key speedbar-file-key-map "\C-c\C-x<" 'org-speedbar-set-agenda-restriction)
18460 (define-key speedbar-file-key-map ">" 'org-agenda-remove-restriction-lock) 19360 (define-key speedbar-file-key-map ">" 'org-agenda-remove-restriction-lock)
18461 (define-key speedbar-file-key-map "\C-c\C-x>" 'org-agenda-remove-restriction-lock) 19361 (define-key speedbar-file-key-map "\C-c\C-x>" 'org-agenda-remove-restriction-lock)
18462 (add-hook 'speedbar-visiting-tag-hook 19362 (add-hook 'speedbar-visiting-tag-hook
18463 (lambda () (and (org-mode-p) (org-show-context 'org-goto)))))) 19363 (lambda () (and (org-mode-p) (org-show-context 'org-goto))))))
18464
18465 19364
18466 ;;; Fixes and Hacks for problems with other packages 19365 ;;; Fixes and Hacks for problems with other packages
18467 19366
18468 ;; Make flyspell not check words in links, to not mess up our keymap 19367 ;; Make flyspell not check words in links, to not mess up our keymap
18469 (defun org-mode-flyspell-verify () 19368 (defun org-mode-flyspell-verify ()