diff options
| author | Carsten Dominik | 2006-05-24 07:54:46 +0000 |
|---|---|---|
| committer | Carsten Dominik | 2006-05-24 07:54:46 +0000 |
| commit | 4b3a9ba762af11f671ee66e2ce335f9fd26fa66e (patch) | |
| tree | fa55861cce12e4dd1de312b0a71a1305ff6d5676 | |
| parent | 55815819d91fe264b178703fe3ce6862fd0bf6f7 (diff) | |
| download | emacs-4b3a9ba762af11f671ee66e2ce335f9fd26fa66e.tar.gz emacs-4b3a9ba762af11f671ee66e2ce335f9fd26fa66e.zip | |
(org-open-at-point): Use renamed variable
`org-confirm-shell-link-function'.
(org-confirm-shell-link-function): Renamed from
`org-confirm-shell-links'.
(org-export-directory): New function.
(org-export-as-ascii, org-export-as-html, org-export-as-xoxo)
(org-export-icalendar): Use `org-export-directory'.
(org-indent-item): Keep cursor position.
(org-link-file-path-type): New option.
(org-export-as-html): Fixed bug with plain lists starting in
column 0.
(org-export-as-html): Removed deadline formatting, this happens
now already in `org-html-handle-time-stamps'.
(org-export-html-style): Deadline class removed.
(org-insert-labeled-timestamps-at-point): New option.
(org-cycle, org-occur, org-scan-tags): Use `org-overview' instead
of `hide-sublevels 1', in case the first headline is not level 1.
(org-overview, org-content): New fuction.
(org-cycle-global-status, org-cycle-subtree-status): Make these
variables buffer-local.
(org-global-cycle): New command.
(org-shifttab): Use `org-global-cycle'.
(org-insert-heading, org-insert-item): Go to end of new
headline/item after creating it.
(org-export-visible): Renames from `org-export-copy-visible'. Now
creates a temporary org-file and applies an exporting command to
it.
(org-table-eval-formula): Support for lisp forms.
(org-agenda-todo-ignore-scheduled): New option.
(org-agenda-get-todos): Use new option
`org-agenda-todo-ignore-scheduled'.
(org-export-html-inline-images): New value `maybe'.
(org-export-as-html): Inlining of images dependent on link
description.
(org-archive-subtree): Check for end-of-buffer before trying
`kill-line'.
(org-agenda-follow-mode): New option.
(org-export-with-tags, org-export-with-timestamps): New options.
(org-html-handle-time-stamps): New function.
(org-keyword-time-regexp): New variable.
(org-agenda-get-todos): Use `org-agenda-todo-list-sublevels'.
(org-agenda-todo-list-sublevels): New option.
(org-html-level-start): When TITLE is nil, just close all levels.
(org-parse-key-lines, org-parse-export-options): Functions
removed, replaced by `org-infile-export-plist'.
(org-combine-plists, org-infile-export-plist)
(org-default-export-plist): New functions.
(org-export-html-preamble, org-export-html-postamble)
(org-export-html-auto-preamble, org-export-html-auto-postamble):
New variables.
(org-export-publishing-directory): New option.
(org-export-as-html, org-export-as-ascii): Use the new property
lists for settings.
(org-export-copy-visible, org-export-as-xoxo): Respect
`org-export-publishing-directory'.
(org-link-search, org-store-link, org-file-apps): Support for
links to BibTeX database entries..
(org-get-current-options, org-set-regexps-and-options): Implement
logging as a startup option.
(org-store-link): Make sure context string is never empty
(org-insert-link): Use relative path when possible.
(org-at-item-checklet-p): New function.
(org-shifttab, org-shiftmetaleft, org-shiftmetaright)
(org-shiftmetaup, org-shiftmetadown, org-metaleft)
(org-metaright, org-metaup, org-metadown, org-shiftup)
(org-shiftdown, org-shiftright, org-shiftleft)
(org-ctrl-c-ctrl-c, org-cycle, org-return, org-meta-return):
Dispatch using `call-interactively'.
(org-call-with-arg): New defsubst.
(org-tag-alist, org-use-fast-tag-selection): New options.
(org-complete): Use `org-tag-alist'.
(org-fast-tag-insert, org-fast-tag-selection): New functions.
(org-next-item, org-previous-item): New commands.
(org-beginning-of-item, org-end-of-item): Added (interactive) to
make command.
(org-shiftup, org-shiftdown): Accommodate the item-navigation commands.
| -rw-r--r-- | lisp/textmodes/org.el | 2185 |
1 files changed, 1600 insertions, 585 deletions
diff --git a/lisp/textmodes/org.el b/lisp/textmodes/org.el index ea9aa4448ee..c7ac5bca365 100644 --- a/lisp/textmodes/org.el +++ b/lisp/textmodes/org.el | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | ;; Author: Carsten Dominik <dominik at science dot uva dot nl> | 5 | ;; Author: Carsten Dominik <dominik at science dot uva dot nl> |
| 6 | ;; Keywords: outlines, hypermedia, calendar, wp | 6 | ;; Keywords: outlines, hypermedia, calendar, wp |
| 7 | ;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/ | 7 | ;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/ |
| 8 | ;; Version: 4.26 | 8 | ;; Version: 4.33 |
| 9 | ;; | 9 | ;; |
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | ;; | 11 | ;; |
| @@ -52,16 +52,17 @@ | |||
| 52 | ;; (define-key global-map "\C-cl" 'org-store-link) | 52 | ;; (define-key global-map "\C-cl" 'org-store-link) |
| 53 | ;; (define-key global-map "\C-ca" 'org-agenda) | 53 | ;; (define-key global-map "\C-ca" 'org-agenda) |
| 54 | ;; | 54 | ;; |
| 55 | ;; If you have downloaded Org-mode from the Web, you must byte-compile | 55 | ;; Furthermore you need to activate font-lock-mode in org-mode buffers. |
| 56 | ;; org.el and put it on your load path. In addition to the Emacs Lisp | 56 | ;; either of the following two lins will do the trick: |
| 57 | ;; lines above, you also need to add the following lines to .emacs: | ||
| 58 | ;; | 57 | ;; |
| 59 | ;; (autoload 'org-mode "org" "Org mode" t) | 58 | ;; (global-font-lock-mode 1) ; for all buffers |
| 60 | ;; (autoload 'org-diary "org" "Diary entries from Org mode") | 59 | ;; (add-hook 'org-mode-hook 'turn-on-font-lock) ; org-mode buffers only |
| 61 | ;; (autoload 'org-agenda "org" "Multi-file agenda from Org mode" t) | 60 | ;; |
| 62 | ;; (autoload 'org-store-link "org" "Store a link to the current location" t) | 61 | ;; If you have downloaded Org-mode from the Web, you have to take additional |
| 63 | ;; (autoload 'orgtbl-mode "org" "Org tables as a minor mode" t) | 62 | ;; action: Byte-compile org.el and org-publish.el and put them together with |
| 64 | ;; (autoload 'turn-on-orgtbl "org" "Org tables as a minor mode") | 63 | ;; org-install.el on your load path. Then also add to your .emacs file: |
| 64 | ;; | ||
| 65 | ;; (require 'org-install) | ||
| 65 | ;; | 66 | ;; |
| 66 | ;; This setup will put all files with extension ".org" into Org-mode. As | 67 | ;; This setup will put all files with extension ".org" into Org-mode. As |
| 67 | ;; an alternative, make the first line of a file look like this: | 68 | ;; an alternative, make the first line of a file look like this: |
| @@ -81,6 +82,57 @@ | |||
| 81 | ;; | 82 | ;; |
| 82 | ;; Changes since version 4.10: | 83 | ;; Changes since version 4.10: |
| 83 | ;; --------------------------- | 84 | ;; --------------------------- |
| 85 | ;; Version 4.33 | ||
| 86 | ;; - New commands to move through plain lists: S-up and S-down. | ||
| 87 | ;; - Bug fixes and documentation update. | ||
| 88 | ;; | ||
| 89 | ;; Version 4.32 | ||
| 90 | ;; - Fast (single-key-per-tag) interface for setting TAGS. | ||
| 91 | ;; - The list of legal tags can be configured globally and locally. | ||
| 92 | ;; - Elisp and Info links (thanks to Todd Neal). | ||
| 93 | ;; - `org-export-publishing-directory' can be an alist, with different | ||
| 94 | ;; directories for different export types. | ||
| 95 | ;; - All context-sensitive commands use `call-interactively' to dispatch. | ||
| 96 | ;; - `org-confirm-shell-links' renamed to `org-confirm-shell-link-function'. | ||
| 97 | ;; - Bug fixes. | ||
| 98 | ;; | ||
| 99 | ;; Version 4.31 | ||
| 100 | ;; - Bug fixes. | ||
| 101 | ;; | ||
| 102 | ;; Version 4.30 | ||
| 103 | ;; - Modified installation: Autoloads have been collected in org-install.el. | ||
| 104 | ;; - Logging (org-log-done) is now a #+STARTUP option. | ||
| 105 | ;; - Checkboxes in plain list items, following up on Frank Ruell's idea. | ||
| 106 | ;; - File links inserted with C-c C-l will use relative paths if the linked | ||
| 107 | ;; file is in the current directory or a subdirectory of it. | ||
| 108 | ;; - New variable `org-link-file-path-type' to specify preference for | ||
| 109 | ;; relative and absolute paths. | ||
| 110 | ;; - New CSS classes for tags, timestamps, timestamp keywords. | ||
| 111 | ;; - Bug and typo fixes. | ||
| 112 | ;; | ||
| 113 | ;; Version 4.29 | ||
| 114 | ;; - Inlining images in HTML export now depends on wheather the link | ||
| 115 | ;; contains a description or not. | ||
| 116 | ;; - TODO items can be scheduled from the global TODO list using C-c C-s. | ||
| 117 | ;; - TODO items already scheduled can be made to disappear from the global | ||
| 118 | ;; todo list, see `org-agenda-todo-ignore-scheduled'. | ||
| 119 | ;; - In Tables, formulas may also be Lisp forms. | ||
| 120 | ;; - Exporting the visible part of an outline with `C-c C-x v' works now | ||
| 121 | ;; for all available exporters. | ||
| 122 | ;; - Bug fixes, lots of them :-( | ||
| 123 | ;; | ||
| 124 | ;; Version 4.28 | ||
| 125 | ;; - Bug fixes. | ||
| 126 | ;; | ||
| 127 | ;; Version 4.27 | ||
| 128 | ;; - HTML exporter generalized to receive external options. | ||
| 129 | ;; As part of the process, author, email and date have been moved to the | ||
| 130 | ;; end of the HTML file. | ||
| 131 | ;; - Support for customizable file search in file links. | ||
| 132 | ;; - BibTeX database links as first application of the above. | ||
| 133 | ;; - New option `org-agenda-todo-list-sublevels' to turn off listing TODO | ||
| 134 | ;; entries that are sublevels of another TODO entry. | ||
| 135 | ;; | ||
| 84 | ;; Version 4.26 | 136 | ;; Version 4.26 |
| 85 | ;; - Bug fixes. | 137 | ;; - Bug fixes. |
| 86 | ;; | 138 | ;; |
| @@ -137,7 +189,7 @@ | |||
| 137 | 189 | ||
| 138 | ;;; Customization variables | 190 | ;;; Customization variables |
| 139 | 191 | ||
| 140 | (defvar org-version "4.26" | 192 | (defvar org-version "4.33" |
| 141 | "The version number of the file org.el.") | 193 | "The version number of the file org.el.") |
| 142 | (defun org-version () | 194 | (defun org-version () |
| 143 | (interactive) | 195 | (interactive) |
| @@ -325,6 +377,18 @@ An entry can be toggled between QUOTE and normal with | |||
| 325 | :tag "Org Cycle" | 377 | :tag "Org Cycle" |
| 326 | :group 'org-structure) | 378 | :group 'org-structure) |
| 327 | 379 | ||
| 380 | (defcustom org-cycle-global-at-bob t | ||
| 381 | "Cycle globally if cursor is at beginning of buffer and not at a headline. | ||
| 382 | This makes it possible to do global cycling without having to use S-TAB or | ||
| 383 | C-u TAB. For this special case to work, the first line of the buffer | ||
| 384 | must not be a headline - it may be empty ot some other text. When used in | ||
| 385 | this way, `org-cycle-hook' is disables temporarily, to make sure the | ||
| 386 | cursor stays at the beginning of the buffer. | ||
| 387 | When this option is nil, don't do anything special at the beginning | ||
| 388 | of the buffer." | ||
| 389 | :group 'org-cycle | ||
| 390 | :type 'boolean) | ||
| 391 | |||
| 328 | (defcustom org-cycle-emulate-tab t | 392 | (defcustom org-cycle-emulate-tab t |
| 329 | "Where should `org-cycle' emulate TAB. | 393 | "Where should `org-cycle' emulate TAB. |
| 330 | nil Never | 394 | nil Never |
| @@ -376,6 +440,11 @@ body starts at column 0, indentation is not changed at all." | |||
| 376 | :group 'org-edit-structure | 440 | :group 'org-edit-structure |
| 377 | :type 'boolean) | 441 | :type 'boolean) |
| 378 | 442 | ||
| 443 | (defcustom org-insert-heading-hook nil | ||
| 444 | "Hook being run after inserting a new heading." | ||
| 445 | :group 'org-edit-structure | ||
| 446 | :type 'boolean) | ||
| 447 | |||
| 379 | (defcustom org-enable-fixed-width-editor t | 448 | (defcustom org-enable-fixed-width-editor t |
| 380 | "Non-nil means, lines starting with \":\" are treated as fixed-width. | 449 | "Non-nil means, lines starting with \":\" are treated as fixed-width. |
| 381 | This currently only means, they are never auto-wrapped. | 450 | This currently only means, they are never auto-wrapped. |
| @@ -756,6 +825,23 @@ additional URL: prefix, so the format would be \"<URL:%s>\"." | |||
| 756 | (const :tag "\"<URL:%s>\" (e.g. <URL:http://www.there.com>)" "<URL:%s>") | 825 | (const :tag "\"<URL:%s>\" (e.g. <URL:http://www.there.com>)" "<URL:%s>") |
| 757 | (string :tag "Other" :value "<%s>"))) | 826 | (string :tag "Other" :value "<%s>"))) |
| 758 | 827 | ||
| 828 | (defcustom org-link-file-path-type 'adaptive | ||
| 829 | "How the path name in file links should be stored. | ||
| 830 | Valid values are: | ||
| 831 | |||
| 832 | relative relative to the current directory, i.e. the directory of the file | ||
| 833 | into which the link is being inserted. | ||
| 834 | absolute absolute path, if possible with ~ for home directory. | ||
| 835 | noabbrev absolute path, no abbreviation of home directory. | ||
| 836 | adaptive Use relative path for files in the current directory and sub- | ||
| 837 | directories of it. For other files, use an absolute path." | ||
| 838 | :group 'org-link | ||
| 839 | :type '(choice | ||
| 840 | (const relative) | ||
| 841 | (const absolute) | ||
| 842 | (const noabbrev) | ||
| 843 | (const adaptive))) | ||
| 844 | |||
| 759 | (defcustom org-activate-links '(bracket angle plain radio tag date) | 845 | (defcustom org-activate-links '(bracket angle plain radio tag date) |
| 760 | "Types of links that should be activated in Org-mode files. | 846 | "Types of links that should be activated in Org-mode files. |
| 761 | This is a list of symbols, each leading to the activation of a certain link | 847 | This is a list of symbols, each leading to the activation of a certain link |
| @@ -898,15 +984,32 @@ When nil, an error will be generated." | |||
| 898 | :group 'org-link-follow | 984 | :group 'org-link-follow |
| 899 | :type 'boolean) | 985 | :type 'boolean) |
| 900 | 986 | ||
| 901 | (defcustom org-confirm-shell-links 'yes-or-no-p | 987 | (defcustom org-confirm-shell-link-function 'yes-or-no-p |
| 902 | "Non-nil means, ask for confirmation before executing shell links. | 988 | "Non-nil means, ask for confirmation before executing shell links. |
| 903 | Shell links can be dangerous, just thing about a link | 989 | Shell links can be dangerous, just thing about a link |
| 904 | 990 | ||
| 905 | [[shell:rm -rf ~/*][Google Search]] | 991 | [[shell:rm -rf ~/*][Google Search]] |
| 906 | 992 | ||
| 907 | This link would show up in your Org-mode document as \"Google Search\" | 993 | This link would show up in your Org-mode document as \"Google Search\" |
| 908 | but really it would remove your entire home directory. Dangerous indeed. | 994 | but really it would remove your entire home directory. |
| 909 | Therefore I *definitely* advise agains setting this varaiable to nil. | 995 | Therefore I *definitely* advise against setting this variable to nil. |
| 996 | Just change it to `y-or-n-p' of you want to confirm with a single key press | ||
| 997 | rather than having to type \"yes\"." | ||
| 998 | :group 'org-link-follow | ||
| 999 | :type '(choice | ||
| 1000 | (const :tag "with yes-or-no (safer)" yes-or-no-p) | ||
| 1001 | (const :tag "with y-or-n (faster)" y-or-n-p) | ||
| 1002 | (const :tag "no confirmation (dangerous)" nil))) | ||
| 1003 | |||
| 1004 | (defcustom org-confirm-elisp-link-function 'yes-or-no-p | ||
| 1005 | "Non-nil means, ask for confirmation before executing elisp links. | ||
| 1006 | Elisp links can be dangerous, just thing about a link | ||
| 1007 | |||
| 1008 | [[elisp:(shell-command \"rm -rf ~/*\")][Google Search]] | ||
| 1009 | |||
| 1010 | This link would show up in your Org-mode document as \"Google Search\" | ||
| 1011 | but really it would remove your entire home directory. | ||
| 1012 | Therefore I *definitely* advise against setting this variable to nil. | ||
| 910 | Just change it to `y-or-n-p' of you want to confirm with a single key press | 1013 | Just change it to `y-or-n-p' of you want to confirm with a single key press |
| 911 | rather than having to type \"yes\"." | 1014 | rather than having to type \"yes\"." |
| 912 | :group 'org-link-follow | 1015 | :group 'org-link-follow |
| @@ -934,7 +1037,11 @@ for some files for which the OS does not have a good default. | |||
| 934 | See `org-file-apps'.") | 1037 | See `org-file-apps'.") |
| 935 | 1038 | ||
| 936 | (defconst org-file-apps-defaults-windowsnt | 1039 | (defconst org-file-apps-defaults-windowsnt |
| 937 | '((t . (w32-shell-execute "open" file))) | 1040 | (list (cons t |
| 1041 | (list (if (featurep 'xemacs) | ||
| 1042 | 'mswindows-shell-execute | ||
| 1043 | 'w32-shell-execute) | ||
| 1044 | "open" 'file))) | ||
| 938 | "Default file applications on a Windows NT system. | 1045 | "Default file applications on a Windows NT system. |
| 939 | The system \"open\" is used for most files. | 1046 | The system \"open\" is used for most files. |
| 940 | See `org-file-apps'.") | 1047 | See `org-file-apps'.") |
| @@ -946,18 +1053,25 @@ See `org-file-apps'.") | |||
| 946 | ("ltx" . emacs) | 1053 | ("ltx" . emacs) |
| 947 | ("org" . emacs) | 1054 | ("org" . emacs) |
| 948 | ("el" . emacs) | 1055 | ("el" . emacs) |
| 1056 | ("bib" . emacs) | ||
| 949 | ) | 1057 | ) |
| 950 | "External applications for opening `file:path' items in a document. | 1058 | "External applications for opening `file:path' items in a document. |
| 951 | Org-mode uses system defaults for different file types, but | 1059 | Org-mode uses system defaults for different file types, but |
| 952 | you can use this variable to set the application for a given file | 1060 | you can use this variable to set the application for a given file |
| 953 | extension. The entries in this list are cons cells with a file extension | 1061 | extension. The entries in this list are cons cells where the car identifies |
| 954 | and the corresponding command. Possible values for the command are: | 1062 | files and the cdr the corresponding command. Possible values for the |
| 955 | `emacs' The file will be visited by the current Emacs process. | 1063 | file identifier are |
| 956 | `default' Use the default application for this file type. | 1064 | \"ext\" A string identifying an extension |
| 957 | string A command to be executed by a shell; %s will be replaced | 1065 | `directory' Matches a directory |
| 958 | by the path to the file. | 1066 | t Default for all remaining files |
| 959 | sexp A Lisp form which will be evaluated. The file path will | 1067 | |
| 960 | be available in the Lisp variable `file'. | 1068 | Possible values for the command are: |
| 1069 | `emacs' The file will be visited by the current Emacs process. | ||
| 1070 | `default' Use the default application for this file type. | ||
| 1071 | string A command to be executed by a shell; %s will be replaced | ||
| 1072 | by the path to the file. | ||
| 1073 | sexp A Lisp form which will be evaluated. The file path will | ||
| 1074 | be available in the Lisp variable `file'. | ||
| 961 | For more examples, see the system specific constants | 1075 | For more examples, see the system specific constants |
| 962 | `org-file-apps-defaults-macosx' | 1076 | `org-file-apps-defaults-macosx' |
| 963 | `org-file-apps-defaults-windowsnt' | 1077 | `org-file-apps-defaults-windowsnt' |
| @@ -1085,7 +1199,12 @@ Lisp variable `state'." | |||
| 1085 | (defcustom org-log-done nil | 1199 | (defcustom org-log-done nil |
| 1086 | "When set, insert a (non-active) time stamp when TODO entry is marked DONE. | 1200 | "When set, insert a (non-active) time stamp when TODO entry is marked DONE. |
| 1087 | When the state of an entry is changed from nothing to TODO, remove a previous | 1201 | When the state of an entry is changed from nothing to TODO, remove a previous |
| 1088 | closing date." | 1202 | closing date. |
| 1203 | This can also be configured on a per-file basis by adding one of | ||
| 1204 | the following lines anywhere in the buffer: | ||
| 1205 | |||
| 1206 | #+STARTUP: logging | ||
| 1207 | #+STARTUP: nologging" | ||
| 1089 | :group 'org-todo | 1208 | :group 'org-todo |
| 1090 | :type 'boolean) | 1209 | :type 'boolean) |
| 1091 | 1210 | ||
| @@ -1110,6 +1229,14 @@ This is the priority an item get if no explicit priority is given." | |||
| 1110 | :tag "Org Time" | 1229 | :tag "Org Time" |
| 1111 | :group 'org) | 1230 | :group 'org) |
| 1112 | 1231 | ||
| 1232 | (defcustom org-insert-labeled-timestamps-at-point nil | ||
| 1233 | "Non-nil means, SCHEDULED and DEADLINE timestamps are inserted at point. | ||
| 1234 | When nil, these labeled time stamps are forces into the second line of an | ||
| 1235 | entry, just after the headline. When scheduling from the global TODO list, | ||
| 1236 | the time stamp will always be forced into the second line." | ||
| 1237 | :group 'org-time | ||
| 1238 | :type 'boolean) | ||
| 1239 | |||
| 1113 | (defconst org-time-stamp-formats '("<%Y-%m-%d %a>" . "<%Y-%m-%d %a %H:%M>") | 1240 | (defconst org-time-stamp-formats '("<%Y-%m-%d %a>" . "<%Y-%m-%d %a %H:%M>") |
| 1114 | "Formats for `format-time-string' which are used for time stamps. | 1241 | "Formats for `format-time-string' which are used for time stamps. |
| 1115 | It is not recommended to change this constant.") | 1242 | It is not recommended to change this constant.") |
| @@ -1149,6 +1276,32 @@ moved to the new date." | |||
| 1149 | :tag "Org Tags" | 1276 | :tag "Org Tags" |
| 1150 | :group 'org) | 1277 | :group 'org) |
| 1151 | 1278 | ||
| 1279 | (defcustom org-tag-alist nil | ||
| 1280 | "List of tags allowed in Org-mode files. | ||
| 1281 | When this list is nil, Org-mode will base TAG input on what is already in the | ||
| 1282 | buffer. | ||
| 1283 | The value of this variable is an alist, the car may be (and should) be a | ||
| 1284 | character that is used to select that tag through the fast-tag-selection | ||
| 1285 | interface. See the manual for details." | ||
| 1286 | :group 'org-tags | ||
| 1287 | :type '(repeat | ||
| 1288 | (cons (character) (string :tag "Tag")))) | ||
| 1289 | |||
| 1290 | (defcustom org-use-fast-tag-selection 'auto | ||
| 1291 | "Non-nil means, use fast tag selection scheme. | ||
| 1292 | This is a special interface to select and deselect tags with single keys. | ||
| 1293 | When nil, fast selection is never used. | ||
| 1294 | When the symbol `auto', fast selection is used if and only if selection | ||
| 1295 | characters for tags have been configured, either through the variable | ||
| 1296 | `org-tag-alist' or through a #+TAGS line in the buffer. | ||
| 1297 | When t, fast selection is always used and selection keys are assigned | ||
| 1298 | automatically if necessary." | ||
| 1299 | :group 'org-tags | ||
| 1300 | :type '(choice | ||
| 1301 | (const :tag "Always" t) | ||
| 1302 | (const :tag "Never" nil) | ||
| 1303 | (const :tag "When selection characters are configured" 'auto))) | ||
| 1304 | |||
| 1152 | (defcustom org-tags-column 48 | 1305 | (defcustom org-tags-column 48 |
| 1153 | "The column to which tags should be indented in a headline. | 1306 | "The column to which tags should be indented in a headline. |
| 1154 | If this number is positive, it specifies the column. If it is negative, | 1307 | If this number is positive, it specifies the column. If it is negative, |
| @@ -1234,6 +1387,7 @@ key The key (a single char as a string) to be associated with the command. | |||
| 1234 | type The command type, any of the following symbols: | 1387 | type The command type, any of the following symbols: |
| 1235 | todo Entries with a specific TODO keyword, in all agenda files. | 1388 | todo Entries with a specific TODO keyword, in all agenda files. |
| 1236 | tags Tags match in all agenda files. | 1389 | tags Tags match in all agenda files. |
| 1390 | tags-todo Tags match in all agenda files, TODO entries only. | ||
| 1237 | todo-tree Sparse tree of specific TODO keyword in *current* file. | 1391 | todo-tree Sparse tree of specific TODO keyword in *current* file. |
| 1238 | tags-tree Sparse tree with all tags matches in *current* file. | 1392 | tags-tree Sparse tree with all tags matches in *current* file. |
| 1239 | occur-tree Occur sparse tree for current file. | 1393 | occur-tree Occur sparse tree for current file. |
| @@ -1246,13 +1400,31 @@ match What to search for: | |||
| 1246 | (list (string :tag "Key") | 1400 | (list (string :tag "Key") |
| 1247 | (choice :tag "Type" | 1401 | (choice :tag "Type" |
| 1248 | (const :tag "Tags search in all agenda files" tags) | 1402 | (const :tag "Tags search in all agenda files" tags) |
| 1403 | (const :tag "Tags search of TODO entries, all agenda files" tags-todo) | ||
| 1249 | (const :tag "TODO keyword search in all agenda files" todo) | 1404 | (const :tag "TODO keyword search in all agenda files" todo) |
| 1250 | (const :tag "Tags sparse tree in current buffer" tags-tree) | 1405 | (const :tag "Tags sparse tree in current buffer" tags-tree) |
| 1251 | (const :tag "TODO keyword tree in current buffer" todo-tree) | 1406 | (const :tag "TODO keyword tree in current buffer" todo-tree) |
| 1252 | (const :tag "Occur tree in current buffer" occur-tree)) | 1407 | (const :tag "Occur tree in current buffer" occur-tree)) |
| 1253 | (string :tag "Match")))) | 1408 | (string :tag "Match")))) |
| 1254 | 1409 | ||
| 1255 | (defcustom org-agenda-include-all-todo t | 1410 | ;; FIXME: Need a toggle for this variable, maybe a mode in the agenda buffer? |
| 1411 | (defcustom org-agenda-todo-list-sublevels t | ||
| 1412 | "Non-nil means, check also the sublevels of a TODO entry for TODO entries. | ||
| 1413 | When nil, the sublevels of a TODO entry are not checked, resulting in | ||
| 1414 | potentially much shorter TODO lists." | ||
| 1415 | :group 'org-agenda | ||
| 1416 | :group 'org-todo | ||
| 1417 | :type 'boolean) | ||
| 1418 | |||
| 1419 | (defcustom org-agenda-todo-ignore-scheduled nil | ||
| 1420 | "Non-nil means, don't show scheduled entries in the global todo list. | ||
| 1421 | The idea behind this is that by scheduling it, you have already taken care | ||
| 1422 | of this item." | ||
| 1423 | :group 'org-agenda | ||
| 1424 | :group 'org-todo | ||
| 1425 | :type 'boolean) | ||
| 1426 | |||
| 1427 | (defcustom org-agenda-include-all-todo nil | ||
| 1256 | "Non-nil means, the agenda will always contain all TODO entries. | 1428 | "Non-nil means, the agenda will always contain all TODO entries. |
| 1257 | When nil, date-less entries will only be shown if `org-agenda' is called | 1429 | When nil, date-less entries will only be shown if `org-agenda' is called |
| 1258 | with a prefix argument. | 1430 | with a prefix argument. |
| @@ -1274,7 +1446,7 @@ forth between agenda and calendar." | |||
| 1274 | :group 'org-agenda | 1446 | :group 'org-agenda |
| 1275 | :type 'sexp) | 1447 | :type 'sexp) |
| 1276 | 1448 | ||
| 1277 | (defgroup org-agenda-window-setup nil | 1449 | (defgroup org-agenda-setup nil |
| 1278 | "Options concerning setting up the Agenda window in Org Mode." | 1450 | "Options concerning setting up the Agenda window in Org Mode." |
| 1279 | :tag "Org Agenda Window Setup" | 1451 | :tag "Org Agenda Window Setup" |
| 1280 | :group 'org-agenda) | 1452 | :group 'org-agenda) |
| @@ -1286,6 +1458,11 @@ Needs to be set before org.el is loaded." | |||
| 1286 | :group 'org-agenda-setup | 1458 | :group 'org-agenda-setup |
| 1287 | :type 'boolean) | 1459 | :type 'boolean) |
| 1288 | 1460 | ||
| 1461 | (defcustom org-agenda-start-with-follow-mode nil | ||
| 1462 | "The initial value of follwo-mode in a newly created agenda window." | ||
| 1463 | :group 'org-agenda-setup | ||
| 1464 | :type 'boolean) | ||
| 1465 | |||
| 1289 | (defcustom org-select-timeline-window t | 1466 | (defcustom org-select-timeline-window t |
| 1290 | "Non-nil means, after creating a timeline, move cursor into Timeline window. | 1467 | "Non-nil means, after creating a timeline, move cursor into Timeline window. |
| 1291 | When nil, cursor will remain in the current window." | 1468 | When nil, cursor will remain in the current window." |
| @@ -1482,7 +1659,7 @@ See also the variables `org-agenda-remove-times-when-in-prefix' and | |||
| 1482 | Depending on which command was used last, this may be the compiled version | 1659 | Depending on which command was used last, this may be the compiled version |
| 1483 | of `org-agenda-prefix-format' or `org-timeline-prefix-format'.") | 1660 | of `org-agenda-prefix-format' or `org-timeline-prefix-format'.") |
| 1484 | 1661 | ||
| 1485 | ;; FIXME: There seem to be situations where this does no work. | 1662 | ;; FIXME: There seem to be situations where this does not work. |
| 1486 | (defcustom org-agenda-remove-times-when-in-prefix t | 1663 | (defcustom org-agenda-remove-times-when-in-prefix t |
| 1487 | "Non-nil means, remove duplicate time specifications in agenda items. | 1664 | "Non-nil means, remove duplicate time specifications in agenda items. |
| 1488 | When the format `org-agenda-prefix-format' contains a `%t' specifier, a | 1665 | When the format `org-agenda-prefix-format' contains a `%t' specifier, a |
| @@ -1520,6 +1697,23 @@ When this is the symbol `prefix', only remove tags when | |||
| 1520 | :tag "Org Export General" | 1697 | :tag "Org Export General" |
| 1521 | :group 'org-export) | 1698 | :group 'org-export) |
| 1522 | 1699 | ||
| 1700 | (defcustom org-export-publishing-directory "." | ||
| 1701 | "Path to the location where exported files should be located. | ||
| 1702 | This path may be relative to the directory where the Org-mode file lives. | ||
| 1703 | The default is to put them into the same directory as the Org-mode file. | ||
| 1704 | The variable may also be an alist with export types `:html', `:ascii', | ||
| 1705 | `:ical', or `:xoxo' and the corresponding directories. If a direcoty path | ||
| 1706 | is relative, it is interpreted relative to the directory where the exported | ||
| 1707 | Org-mode files lives." | ||
| 1708 | :group 'org-export-general | ||
| 1709 | :type '(choice | ||
| 1710 | (directory) | ||
| 1711 | (repeat | ||
| 1712 | (cons | ||
| 1713 | (choice :tag "Type" | ||
| 1714 | (const :html) (const :ascii) (const :ical) (const :xoxo)) | ||
| 1715 | (directory))))) | ||
| 1716 | |||
| 1523 | (defcustom org-export-language-setup | 1717 | (defcustom org-export-language-setup |
| 1524 | '(("en" "Author" "Date" "Table of Contents") | 1718 | '(("en" "Author" "Date" "Table of Contents") |
| 1525 | ("da" "Ophavsmand" "Dato" "Indhold") | 1719 | ("da" "Ophavsmand" "Dato" "Indhold") |
| @@ -1591,6 +1785,21 @@ This option can also be set with the +OPTIONS line, e.g. \"\\n:t\"." | |||
| 1591 | :group 'org-export-general | 1785 | :group 'org-export-general |
| 1592 | :type 'boolean) | 1786 | :type 'boolean) |
| 1593 | 1787 | ||
| 1788 | (defcustom org-export-with-timestamps t | ||
| 1789 | "Nil means, do not export time stamps and associated keywords." | ||
| 1790 | :group 'org-export | ||
| 1791 | :type 'boolean) | ||
| 1792 | |||
| 1793 | (defcustom org-export-with-tags t | ||
| 1794 | "Nil means, do not export tags, just remove them from headlines." | ||
| 1795 | :group 'org-export-general | ||
| 1796 | :type 'boolean) | ||
| 1797 | |||
| 1798 | (defcustom org-export-with-timestamps t | ||
| 1799 | "Nil means, do not export timestamps and associated keywords." | ||
| 1800 | :group 'org-export-general | ||
| 1801 | :type 'boolean) | ||
| 1802 | |||
| 1594 | (defgroup org-export-translation nil | 1803 | (defgroup org-export-translation nil |
| 1595 | "Options for translating special ascii sequences for the export backends." | 1804 | "Options for translating special ascii sequences for the export backends." |
| 1596 | :tag "Org Export Translation" | 1805 | :tag "Org Export Translation" |
| @@ -1725,7 +1934,8 @@ Otherwise the buffer will just be saved to a file and stay hidden." | |||
| 1725 | :tag "Org Export XML" | 1934 | :tag "Org Export XML" |
| 1726 | :group 'org-export) | 1935 | :group 'org-export) |
| 1727 | 1936 | ||
| 1728 | (defcustom org-export-xml-type 'xoxo ;kw, if we have only one. | 1937 | ;; FIXME: I am told XOXO is not XML, it is semantic-only HTML. |
| 1938 | (defcustom org-export-xml-type 'xoxo | ||
| 1729 | "The kind of XML to be produced by the XML exporter. | 1939 | "The kind of XML to be produced by the XML exporter. |
| 1730 | Allowed values are: | 1940 | Allowed values are: |
| 1731 | xoxo The XOXO exporter." | 1941 | xoxo The XOXO exporter." |
| @@ -1745,8 +1955,11 @@ xoxo The XOXO exporter." | |||
| 1745 | font-size: 12pt; | 1955 | font-size: 12pt; |
| 1746 | } | 1956 | } |
| 1747 | .title { text-align: center; } | 1957 | .title { text-align: center; } |
| 1748 | .todo, .deadline { color: red; } | 1958 | .todo { color: red; } |
| 1749 | .done { color: green; } | 1959 | .done { color: green; } |
| 1960 | .timestamp { color: grey } | ||
| 1961 | .timestamp-kwd { color: CadetBlue } | ||
| 1962 | .tag { background-color:lightblue; font-weight:normal } | ||
| 1750 | .target { background-color: lavender; } | 1963 | .target { background-color: lavender; } |
| 1751 | pre { | 1964 | pre { |
| 1752 | border: 1pt solid #AEBDCC; | 1965 | border: 1pt solid #AEBDCC; |
| @@ -1796,13 +2009,16 @@ When nil, the links still point to the plain `.org' file." | |||
| 1796 | :group 'org-export-html | 2009 | :group 'org-export-html |
| 1797 | :type 'boolean) | 2010 | :type 'boolean) |
| 1798 | 2011 | ||
| 1799 | (defcustom org-export-html-inline-images t | 2012 | (defcustom org-export-html-inline-images 'maybe |
| 1800 | "Non-nil means, inline images into exported HTML pages. | 2013 | "Non-nil means, inline images into exported HTML pages. |
| 1801 | The link will still be to the original location of the image file. | 2014 | This is done using an <img> tag. When nil, an anchor with href is used to |
| 1802 | So if you are moving the page, lets say to your public HTML site, | 2015 | link to the image. If this option is `maybe', then images in links with |
| 1803 | you will have to move the image and maybe change the link." | 2016 | an empty description will be inlined, while images with a description will |
| 2017 | be linked only." | ||
| 1804 | :group 'org-export-html | 2018 | :group 'org-export-html |
| 1805 | :type 'boolean) | 2019 | :type '(choice (const :tag "Never" nil) |
| 2020 | (const :tag "Always" t) | ||
| 2021 | (const :tag "When there is no description" maybe))) | ||
| 1806 | 2022 | ||
| 1807 | (defcustom org-export-html-expand t | 2023 | (defcustom org-export-html-expand t |
| 1808 | "Non-nil means, for HTML export, treat @<...> as HTML tag. | 2024 | "Non-nil means, for HTML export, treat @<...> as HTML tag. |
| @@ -1847,7 +2063,8 @@ Otherwise, the buffer will just be saved to a file and stay hidden." | |||
| 1847 | 2063 | ||
| 1848 | (defcustom org-combined-agenda-icalendar-file "~/org.ics" | 2064 | (defcustom org-combined-agenda-icalendar-file "~/org.ics" |
| 1849 | "The file name for the iCalendar file covering all agenda files. | 2065 | "The file name for the iCalendar file covering all agenda files. |
| 1850 | This file is created with the command \\[org-export-icalendar-all-agenda-files]." | 2066 | This file is created with the command \\[org-export-icalendar-all-agenda-files]. |
| 2067 | The file name should be absolute." | ||
| 1851 | :group 'org-export-icalendar | 2068 | :group 'org-export-icalendar |
| 1852 | :type 'file) | 2069 | :type 'file) |
| 1853 | 2070 | ||
| @@ -2003,7 +2220,7 @@ color of the frame." | |||
| 2003 | (org-compatible-face | 2220 | (org-compatible-face |
| 2004 | '((((class color) (min-colors 16) (background light)) (:foreground "Orchid")) | 2221 | '((((class color) (min-colors 16) (background light)) (:foreground "Orchid")) |
| 2005 | (((class color) (min-colors 16) (background dark)) (:foreground "LightSteelBlue")) | 2222 | (((class color) (min-colors 16) (background dark)) (:foreground "LightSteelBlue")) |
| 2006 | (((class color) (min-colors 8)) (:foreground "blue")))) ;; FIXME: for dark bg? | 2223 | (((class color) (min-colors 8)) (:foreground "blue")))) |
| 2007 | "Face used for level 7 headlines." | 2224 | "Face used for level 7 headlines." |
| 2008 | :group 'org-faces) | 2225 | :group 'org-faces) |
| 2009 | 2226 | ||
| @@ -2124,7 +2341,7 @@ This face is only used if `org-fontify-done-headline' is set." | |||
| 2124 | (org-compatible-face | 2341 | (org-compatible-face |
| 2125 | '((((class color) (min-colors 16) (background light)) (:foreground "DarkGoldenrod")) | 2342 | '((((class color) (min-colors 16) (background light)) (:foreground "DarkGoldenrod")) |
| 2126 | (((class color) (min-colors 16) (background dark)) (:foreground "LightGoldenrod")) | 2343 | (((class color) (min-colors 16) (background dark)) (:foreground "LightGoldenrod")) |
| 2127 | (((class color) (min-colors 8)) (:foreground "yellow" :weight light)))) ; FIXME: turn off??? | 2344 | (((class color) (min-colors 8)) (:foreground "yellow" :weight light)))) |
| 2128 | "Face used for time grids." | 2345 | "Face used for time grids." |
| 2129 | :group 'org-faces) | 2346 | :group 'org-faces) |
| 2130 | 2347 | ||
| @@ -2193,21 +2410,46 @@ This face is only used if `org-fontify-done-headline' is set." | |||
| 2193 | (defvar org-scheduled-time-regexp nil | 2410 | (defvar org-scheduled-time-regexp nil |
| 2194 | "Matches the SCHEDULED keyword together with a time stamp.") | 2411 | "Matches the SCHEDULED keyword together with a time stamp.") |
| 2195 | (make-variable-buffer-local 'org-scheduled-time-regexp) | 2412 | (make-variable-buffer-local 'org-scheduled-time-regexp) |
| 2413 | (defvar org-closed-time-regexp nil | ||
| 2414 | "Matches the CLOSED keyword together with a time stamp.") | ||
| 2415 | (make-variable-buffer-local 'org-closed-time-regexp) | ||
| 2416 | |||
| 2417 | (defvar org-keyword-time-regexp nil | ||
| 2418 | "Matches any of the 3 keywords, together with the time stamp.") | ||
| 2419 | (make-variable-buffer-local 'org-keyword-time-regexp) | ||
| 2420 | (defvar org-maybe-keyword-time-regexp nil | ||
| 2421 | "Matches a timestamp, possibly preceeded by a keyword.") | ||
| 2422 | (make-variable-buffer-local 'org-keyword-time-regexp) | ||
| 2423 | |||
| 2424 | (defconst org-rm-props '(invisible t face t keymap t intangible t mouse-face t | ||
| 2425 | mouse-map t) | ||
| 2426 | "Properties to remove when a string without properties is wanted.") | ||
| 2427 | |||
| 2428 | (defsubst org-match-string-no-properties (num &optional string) | ||
| 2429 | (if (featurep 'xemacs) | ||
| 2430 | (let ((s (match-string num string))) | ||
| 2431 | (remove-text-properties 0 (length s) org-rm-props s) | ||
| 2432 | s) | ||
| 2433 | (match-string-no-properties num string))) | ||
| 2434 | |||
| 2435 | (defsubst org-no-properties (s) | ||
| 2436 | (remove-text-properties 0 (length s) org-rm-props s) | ||
| 2437 | s) | ||
| 2196 | 2438 | ||
| 2197 | (defun org-set-regexps-and-options () | 2439 | (defun org-set-regexps-and-options () |
| 2198 | "Precompute regular expressions for current buffer." | 2440 | "Precompute regular expressions for current buffer." |
| 2199 | (when (eq major-mode 'org-mode) | 2441 | (when (eq major-mode 'org-mode) |
| 2200 | (let ((re (org-make-options-regexp | 2442 | (let ((re (org-make-options-regexp |
| 2201 | '("CATEGORY" "SEQ_TODO" "PRI_TODO" "TYP_TODO" | 2443 | '("CATEGORY" "SEQ_TODO" "PRI_TODO" "TYP_TODO" |
| 2202 | "STARTUP" "ARCHIVE"))) | 2444 | "STARTUP" "ARCHIVE" "TAGS"))) |
| 2203 | (splitre "[ \t]+") | 2445 | (splitre "[ \t]+") |
| 2204 | kwds int key value cat arch) | 2446 | kwds int key value cat arch tags) |
| 2205 | (save-excursion | 2447 | (save-excursion |
| 2206 | (save-restriction | 2448 | (save-restriction |
| 2207 | (widen) | 2449 | (widen) |
| 2208 | (goto-char (point-min)) | 2450 | (goto-char (point-min)) |
| 2209 | (while (re-search-forward re nil t) | 2451 | (while (re-search-forward re nil t) |
| 2210 | (setq key (match-string 1) value (match-string 2)) | 2452 | (setq key (match-string 1) value (org-match-string-no-properties 2)) |
| 2211 | (cond | 2453 | (cond |
| 2212 | ((equal key "CATEGORY") | 2454 | ((equal key "CATEGORY") |
| 2213 | (if (string-match "[ \t]+$" value) | 2455 | (if (string-match "[ \t]+$" value) |
| @@ -2222,6 +2464,8 @@ This face is only used if `org-fontify-done-headline' is set." | |||
| 2222 | ((equal key "TYP_TODO") | 2464 | ((equal key "TYP_TODO") |
| 2223 | (setq int 'type | 2465 | (setq int 'type |
| 2224 | kwds (append kwds (org-split-string value splitre)))) | 2466 | kwds (append kwds (org-split-string value splitre)))) |
| 2467 | ((equal key "TAGS") | ||
| 2468 | (setq tags (append tags (org-split-string value splitre)))) | ||
| 2225 | ((equal key "STARTUP") | 2469 | ((equal key "STARTUP") |
| 2226 | (let ((opts (org-split-string value splitre)) | 2470 | (let ((opts (org-split-string value splitre)) |
| 2227 | (set '(("fold" org-startup-folded t) | 2471 | (set '(("fold" org-startup-folded t) |
| @@ -2235,6 +2479,8 @@ This face is only used if `org-fontify-done-headline' is set." | |||
| 2235 | ("oddeven" org-odd-levels-only nil) | 2479 | ("oddeven" org-odd-levels-only nil) |
| 2236 | ("align" org-startup-align-all-tables t) | 2480 | ("align" org-startup-align-all-tables t) |
| 2237 | ("noalign" org-startup-align-all-tables nil) | 2481 | ("noalign" org-startup-align-all-tables nil) |
| 2482 | ("logging" org-log-done t) | ||
| 2483 | ("nologging" org-log-done nil) | ||
| 2238 | ("dlcheck" org-startup-with-deadline-check t) | 2484 | ("dlcheck" org-startup-with-deadline-check t) |
| 2239 | ("nodlcheck" org-startup-with-deadline-check nil))) | 2485 | ("nodlcheck" org-startup-with-deadline-check nil))) |
| 2240 | l var val) | 2486 | l var val) |
| @@ -2250,7 +2496,20 @@ This face is only used if `org-fontify-done-headline' is set." | |||
| 2250 | (and cat (set (make-local-variable 'org-category) cat)) | 2496 | (and cat (set (make-local-variable 'org-category) cat)) |
| 2251 | (and kwds (set (make-local-variable 'org-todo-keywords) kwds)) | 2497 | (and kwds (set (make-local-variable 'org-todo-keywords) kwds)) |
| 2252 | (and arch (set (make-local-variable 'org-archive-location) arch)) | 2498 | (and arch (set (make-local-variable 'org-archive-location) arch)) |
| 2253 | (and int (set (make-local-variable 'org-todo-interpretation) int))) | 2499 | (and int (set (make-local-variable 'org-todo-interpretation) int)) |
| 2500 | (when tags | ||
| 2501 | (let (e tg c tgs) | ||
| 2502 | (while (setq e (pop tags)) | ||
| 2503 | (if (string-match "^\\([0-9a-zA-Z_@]+\\)(\\(.\\))$" e) | ||
| 2504 | (push (cons (match-string 1 e) | ||
| 2505 | (string-to-char (match-string 2 e))) | ||
| 2506 | tgs) | ||
| 2507 | (push (list e) tgs))) | ||
| 2508 | (set (make-local-variable 'org-tag-alist) nil) | ||
| 2509 | (while (setq e (pop tgs)) | ||
| 2510 | (or (assoc (car e) org-tag-alist) | ||
| 2511 | (push e org-tag-alist)))))) | ||
| 2512 | |||
| 2254 | ;; Compute the regular expressions and other local variables | 2513 | ;; Compute the regular expressions and other local variables |
| 2255 | (setq org-todo-kwd-priority-p (equal org-todo-interpretation 'priority) | 2514 | (setq org-todo-kwd-priority-p (equal org-todo-interpretation 'priority) |
| 2256 | org-todo-kwd-max-priority (1- (length org-todo-keywords)) | 2515 | org-todo-kwd-max-priority (1- (length org-todo-keywords)) |
| @@ -2282,7 +2541,20 @@ This face is only used if `org-fontify-done-headline' is set." | |||
| 2282 | org-scheduled-regexp | 2541 | org-scheduled-regexp |
| 2283 | (concat "\\<" org-scheduled-string) | 2542 | (concat "\\<" org-scheduled-string) |
| 2284 | org-scheduled-time-regexp | 2543 | org-scheduled-time-regexp |
| 2285 | (concat "\\<" org-scheduled-string " *<\\([^>]+\\)>")) | 2544 | (concat "\\<" org-scheduled-string " *<\\([^>]+\\)>") |
| 2545 | org-closed-time-regexp | ||
| 2546 | (concat "\\<" org-closed-string " *\\[\\([^]]+\\)\\]") | ||
| 2547 | org-keyword-time-regexp | ||
| 2548 | (concat "\\<\\(" org-scheduled-string | ||
| 2549 | "\\|" org-deadline-string | ||
| 2550 | "\\|" org-closed-string "\\)" | ||
| 2551 | " *[[<]\\([^]>]+\\)[]>]") ;; FIXME: is this correct? | ||
| 2552 | org-maybe-keyword-time-regexp | ||
| 2553 | (concat "\\(\\<\\(" org-scheduled-string | ||
| 2554 | "\\|" org-deadline-string | ||
| 2555 | "\\|" org-closed-string "\\)\\)?" | ||
| 2556 | " *\\([[<][0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}[^]\r\n>]*?[]>]\\)")) ;; FIXME: is this correct? | ||
| 2557 | |||
| 2286 | (org-set-font-lock-defaults))) | 2558 | (org-set-font-lock-defaults))) |
| 2287 | 2559 | ||
| 2288 | ;; Tell the compiler about dynamically scoped variables, | 2560 | ;; Tell the compiler about dynamically scoped variables, |
| @@ -2298,14 +2570,9 @@ This face is only used if `org-fontify-done-headline' is set." | |||
| 2298 | (defvar mark-active) ; Emacs only, not available in XEmacs. | 2570 | (defvar mark-active) ; Emacs only, not available in XEmacs. |
| 2299 | (defvar timecnt) ; dynamically scoped parameter | 2571 | (defvar timecnt) ; dynamically scoped parameter |
| 2300 | (defvar levels-open) ; dynamically scoped parameter | 2572 | (defvar levels-open) ; dynamically scoped parameter |
| 2301 | (defvar title) ; dynamically scoped parameter | ||
| 2302 | (defvar author) ; dynamically scoped parameter | ||
| 2303 | (defvar email) ; dynamically scoped parameter | ||
| 2304 | (defvar text) ; dynamically scoped parameter | ||
| 2305 | (defvar entry) ; dynamically scoped parameter | 2573 | (defvar entry) ; dynamically scoped parameter |
| 2306 | (defvar date) ; dynamically scoped parameter | 2574 | (defvar date) ; dynamically scoped parameter |
| 2307 | (defvar language) ; dynamically scoped parameter | 2575 | (defvar description) ; dynamically scoped parameter |
| 2308 | (defvar options) ; dynamically scoped parameter | ||
| 2309 | (defvar ans1) ; dynamically scoped parameter | 2576 | (defvar ans1) ; dynamically scoped parameter |
| 2310 | (defvar ans2) ; dynamically scoped parameter | 2577 | (defvar ans2) ; dynamically scoped parameter |
| 2311 | (defvar starting-day) ; local variable | 2578 | (defvar starting-day) ; local variable |
| @@ -2330,6 +2597,9 @@ This face is only used if `org-fontify-done-headline' is set." | |||
| 2330 | (defvar annotation) ; from remember.el, dynamically scoped in `remember-mode' | 2597 | (defvar annotation) ; from remember.el, dynamically scoped in `remember-mode' |
| 2331 | (defvar initial) ; from remember.el, dynamically scoped in `remember-mode' | 2598 | (defvar initial) ; from remember.el, dynamically scoped in `remember-mode' |
| 2332 | (defvar orgtbl-mode) ; defined later in this file | 2599 | (defvar orgtbl-mode) ; defined later in this file |
| 2600 | (defvar Info-current-file) ; from info.el | ||
| 2601 | (defvar Info-current-node) ; from info.el | ||
| 2602 | |||
| 2333 | ;;; Define the mode | 2603 | ;;; Define the mode |
| 2334 | 2604 | ||
| 2335 | (defvar org-mode-map | 2605 | (defvar org-mode-map |
| @@ -2372,11 +2642,31 @@ can be exported as a structured ASCII or HTML file. | |||
| 2372 | The following commands are available: | 2642 | The following commands are available: |
| 2373 | 2643 | ||
| 2374 | \\{org-mode-map}" | 2644 | \\{org-mode-map}" |
| 2645 | |||
| 2646 | ;; Get rid of Outline menus, they are not needed | ||
| 2647 | ;; Need to do this here because define-derived-mode sets up | ||
| 2648 | ;; the keymap so late. | ||
| 2649 | (if (featurep 'xemacs) | ||
| 2650 | (if org-noutline-p | ||
| 2651 | (progn | ||
| 2652 | (easy-menu-remove outline-mode-menu-heading) | ||
| 2653 | (easy-menu-remove outline-mode-menu-show) | ||
| 2654 | (easy-menu-remove outline-mode-menu-hide)) | ||
| 2655 | (delete-menu-item '("Headings")) | ||
| 2656 | (delete-menu-item '("Show")) | ||
| 2657 | (delete-menu-item '("Hide")) | ||
| 2658 | (set-menubar-dirty-flag)) | ||
| 2659 | (define-key org-mode-map [menu-bar headings] 'undefined) | ||
| 2660 | (define-key org-mode-map [menu-bar hide] 'undefined) | ||
| 2661 | (define-key org-mode-map [menu-bar show] 'undefined)) | ||
| 2662 | |||
| 2375 | (easy-menu-add org-org-menu) | 2663 | (easy-menu-add org-org-menu) |
| 2376 | (easy-menu-add org-tbl-menu) | 2664 | (easy-menu-add org-tbl-menu) |
| 2377 | (org-install-agenda-files-menu) | 2665 | (org-install-agenda-files-menu) |
| 2378 | (if org-descriptive-links (org-add-to-invisibility-spec '(org-link))) | 2666 | (if org-descriptive-links (org-add-to-invisibility-spec '(org-link))) |
| 2379 | (org-add-to-invisibility-spec '(org-cwidth)) | 2667 | (org-add-to-invisibility-spec '(org-cwidth)) |
| 2668 | (when (featurep 'xemacs) | ||
| 2669 | (set (make-local-variable 'line-move-ignore-invisible) t)) | ||
| 2380 | (setq outline-regexp "\\*+") | 2670 | (setq outline-regexp "\\*+") |
| 2381 | ;;(setq outline-regexp "\\(?:\\*+\\|[ \t]*\\(?:[-+*]\\|[0-9]+[.)]\\) \\)") | 2671 | ;;(setq outline-regexp "\\(?:\\*+\\|[ \t]*\\(?:[-+*]\\|[0-9]+[.)]\\) \\)") |
| 2382 | (setq outline-level 'org-outline-level) | 2672 | (setq outline-level 'org-outline-level) |
| @@ -2405,19 +2695,6 @@ The following commands are available: | |||
| 2405 | (= (point-min) (point-max))) | 2695 | (= (point-min) (point-max))) |
| 2406 | (insert " -*- mode: org -*-\n\n")) | 2696 | (insert " -*- mode: org -*-\n\n")) |
| 2407 | 2697 | ||
| 2408 | ;; Get rid of Outline menus, they are not needed | ||
| 2409 | ;; Need to do this here because define-derived-mode sets up | ||
| 2410 | ;; the keymap so late. | ||
| 2411 | (if (featurep 'xemacs) | ||
| 2412 | (progn | ||
| 2413 | (delete-menu-item '("Headings")) | ||
| 2414 | (delete-menu-item '("Show")) | ||
| 2415 | (delete-menu-item '("Hide")) | ||
| 2416 | (set-menubar-dirty-flag)) | ||
| 2417 | (define-key org-mode-map [menu-bar headings] 'undefined) | ||
| 2418 | (define-key org-mode-map [menu-bar hide] 'undefined) | ||
| 2419 | (define-key org-mode-map [menu-bar show] 'undefined)) | ||
| 2420 | |||
| 2421 | (unless org-inhibit-startup | 2698 | (unless org-inhibit-startup |
| 2422 | (if org-startup-align-all-tables | 2699 | (if org-startup-align-all-tables |
| 2423 | (org-table-map-tables 'org-table-align)) | 2700 | (org-table-map-tables 'org-table-align)) |
| @@ -2430,24 +2707,13 @@ The following commands are available: | |||
| 2430 | (let ((this-command 'org-cycle) (last-command 'org-cycle)) | 2707 | (let ((this-command 'org-cycle) (last-command 'org-cycle)) |
| 2431 | (org-cycle '(4)) (org-cycle '(4)))))))) | 2708 | (org-cycle '(4)) (org-cycle '(4)))))))) |
| 2432 | 2709 | ||
| 2710 | (defsubst org-call-with-arg (command arg) | ||
| 2711 | "Call COMMAND interactively, but pretend prefix are was ARG." | ||
| 2712 | (let ((current-prefix-arg arg)) (call-interactively command))) | ||
| 2713 | |||
| 2433 | (defsubst org-current-line (&optional pos) | 2714 | (defsubst org-current-line (&optional pos) |
| 2434 | (+ (if (bolp) 1 0) (count-lines (point-min) (or pos (point))))) | 2715 | (+ (if (bolp) 1 0) (count-lines (point-min) (or pos (point))))) |
| 2435 | 2716 | ||
| 2436 | (defconst org-rm-props '(invisible t face t keymap t intangible t mouse-face t | ||
| 2437 | mouse-map t) | ||
| 2438 | "Properties to remove when a string without properties is wanted.") | ||
| 2439 | |||
| 2440 | (defsubst org-match-string-no-properties (num &optional string) | ||
| 2441 | (if (featurep 'xemacs) | ||
| 2442 | (let ((s (match-string num string))) | ||
| 2443 | (remove-text-properties 0 (length s) org-rm-props s) | ||
| 2444 | s) | ||
| 2445 | (match-string-no-properties num string))) | ||
| 2446 | |||
| 2447 | (defsubst org-no-properties (s) | ||
| 2448 | (remove-text-properties 0 (length s) org-rm-props s) | ||
| 2449 | s) | ||
| 2450 | |||
| 2451 | (defun org-current-time () | 2717 | (defun org-current-time () |
| 2452 | "Current time, possibly rounded to `org-time-stamp-rounding-minutes'." | 2718 | "Current time, possibly rounded to `org-time-stamp-rounding-minutes'." |
| 2453 | (if (> org-time-stamp-rounding-minutes 0) | 2719 | (if (> org-time-stamp-rounding-minutes 0) |
| @@ -2488,7 +2754,7 @@ that will be added to PLIST. Returns the string that was modified." | |||
| 2488 | 2754 | ||
| 2489 | (defconst org-non-link-chars "]\t\n\r<>") | 2755 | (defconst org-non-link-chars "]\t\n\r<>") |
| 2490 | (defconst org-link-types '("https?" "ftp" "mailto" "file" "news" "bbdb" "vm" | 2756 | (defconst org-link-types '("https?" "ftp" "mailto" "file" "news" "bbdb" "vm" |
| 2491 | "wl" "mhe" "rmail" "gnus" "shell")) | 2757 | "wl" "mhe" "rmail" "gnus" "shell" "info" "elisp")) |
| 2492 | (defconst org-link-re-with-space | 2758 | (defconst org-link-re-with-space |
| 2493 | (concat | 2759 | (concat |
| 2494 | "<?\\(" (mapconcat 'identity org-link-types "\\|") "\\):" | 2760 | "<?\\(" (mapconcat 'identity org-link-types "\\|") "\\):" |
| @@ -2719,11 +2985,13 @@ between words." | |||
| 2719 | (let* ((em org-fontify-emphasized-text) | 2985 | (let* ((em org-fontify-emphasized-text) |
| 2720 | (lk org-activate-links) | 2986 | (lk org-activate-links) |
| 2721 | (org-font-lock-extra-keywords | 2987 | (org-font-lock-extra-keywords |
| 2988 | ;; Headlines | ||
| 2722 | (list | 2989 | (list |
| 2723 | '("^\\(\\**\\)\\(\\*\\)\\(.*\\)" (1 (org-get-level-face 1)) | 2990 | '("^\\(\\**\\)\\(\\*\\)\\(.*\\)" (1 (org-get-level-face 1)) |
| 2724 | (2 (org-get-level-face 2)) (3 (org-get-level-face 3))) | 2991 | (2 (org-get-level-face 2)) (3 (org-get-level-face 3))) |
| 2725 | '("^[ \t]*\\(\\(|\\|\\+-[-+]\\).*\\S-\\)" | 2992 | '("^[ \t]*\\(\\(|\\|\\+-[-+]\\).*\\S-\\)" |
| 2726 | (1 'org-table)) | 2993 | (1 'org-table)) |
| 2994 | ;; Links | ||
| 2727 | (if (memq 'angle lk) '(org-activate-angle-links (0 'org-link t))) | 2995 | (if (memq 'angle lk) '(org-activate-angle-links (0 'org-link t))) |
| 2728 | (if (memq 'plain lk) '(org-activate-plain-links (0 'org-link t))) | 2996 | (if (memq 'plain lk) '(org-activate-plain-links (0 'org-link t))) |
| 2729 | (if (memq 'bracket lk) '(org-activate-bracket-links (0 'org-link t))) | 2997 | (if (memq 'bracket lk) '(org-activate-bracket-links (0 'org-link t))) |
| @@ -2733,27 +3001,34 @@ between words." | |||
| 2733 | (if (memq 'tag lk) '(org-activate-tags (1 'org-tag prepend))) | 3001 | (if (memq 'tag lk) '(org-activate-tags (1 'org-tag prepend))) |
| 2734 | (if org-table-limit-column-width | 3002 | (if org-table-limit-column-width |
| 2735 | '(org-hide-wide-columns (0 nil append))) | 3003 | '(org-hide-wide-columns (0 nil append))) |
| 3004 | ;; TODO lines | ||
| 2736 | (list (concat "^\\*+[ \t]*" org-not-done-regexp) | 3005 | (list (concat "^\\*+[ \t]*" org-not-done-regexp) |
| 2737 | '(1 'org-todo t)) | 3006 | '(1 'org-todo t)) |
| 3007 | ;; Priorities | ||
| 2738 | (list (concat "\\[#[A-Z]\\]") '(0 'org-special-keyword t)) | 3008 | (list (concat "\\[#[A-Z]\\]") '(0 'org-special-keyword t)) |
| 3009 | ;; Special keywords | ||
| 2739 | (list (concat "\\<" org-deadline-string) '(0 'org-special-keyword t)) | 3010 | (list (concat "\\<" org-deadline-string) '(0 'org-special-keyword t)) |
| 2740 | (list (concat "\\<" org-scheduled-string) '(0 'org-special-keyword t)) | 3011 | (list (concat "\\<" org-scheduled-string) '(0 'org-special-keyword t)) |
| 2741 | (list (concat "\\<" org-closed-string) '(0 'org-special-keyword t)) | 3012 | (list (concat "\\<" org-closed-string) '(0 'org-special-keyword t)) |
| 2742 | ; (if em '("\\(\\W\\|^\\)\\(\\*\\w+\\*\\)\\(\\W\\|$\\)" 2 'bold prepend)) | 3013 | ;; Emphasis |
| 2743 | ; (if em '("\\(\\W\\|^\\)\\(/\\w+/\\)\\(\\W\\|$\\)" 2 'italic prepend)) | ||
| 2744 | ; (if em '("\\(\\W\\|^\\)\\(_\\w+_\\)\\(\\W\\|$\\)" 2 'underline prepend)) | ||
| 2745 | (if em (list org-bold-re 2 ''bold 'prepend)) | 3014 | (if em (list org-bold-re 2 ''bold 'prepend)) |
| 2746 | (if em (list org-italic-re 2 ''italic 'prepend)) | 3015 | (if em (list org-italic-re 2 ''italic 'prepend)) |
| 2747 | (if em (list org-underline-re 2 ''underline 'prepend)) | 3016 | (if em (list org-underline-re 2 ''underline 'prepend)) |
| 3017 | ;; Checkboxes, similar to Frank Ruell's org-checklet.el | ||
| 3018 | '("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[ X]\\]\\)" | ||
| 3019 | 2 'bold prepend) | ||
| 3020 | ;; COMMENT | ||
| 2748 | (list (concat "^\\*+[ \t]*\\<\\(" org-comment-string | 3021 | (list (concat "^\\*+[ \t]*\\<\\(" org-comment-string |
| 2749 | "\\|" org-quote-string "\\)\\>") | 3022 | "\\|" org-quote-string "\\)\\>") |
| 2750 | '(1 'org-special-keyword t)) | 3023 | '(1 'org-special-keyword t)) |
| 2751 | '("^#.*" (0 'font-lock-comment-face t)) | 3024 | '("^#.*" (0 'font-lock-comment-face t)) |
| 3025 | ;; DONE | ||
| 2752 | (if org-fontify-done-headline | 3026 | (if org-fontify-done-headline |
| 2753 | (list (concat "^[*]+ +\\<\\(" org-done-string "\\)\\(.*\\)\\>") | 3027 | (list (concat "^[*]+ +\\<\\(" org-done-string "\\)\\(.*\\)\\>") |
| 2754 | '(1 'org-done t) '(2 'org-headline-done t)) | 3028 | '(1 'org-done t) '(2 'org-headline-done t)) |
| 2755 | (list (concat "^[*]+ +\\<\\(" org-done-string "\\)\\>") | 3029 | (list (concat "^[*]+ +\\<\\(" org-done-string "\\)\\>") |
| 2756 | '(1 'org-done t))) | 3030 | '(1 'org-done t))) |
| 3031 | ;; Table stuff | ||
| 2757 | '("^[ \t]*\\(:.*\\)" (1 'org-table t)) | 3032 | '("^[ \t]*\\(:.*\\)" (1 'org-table t)) |
| 2758 | '("| *\\(:?=[^|\n]*\\)" (1 'org-formula t)) | 3033 | '("| *\\(:?=[^|\n]*\\)" (1 'org-formula t)) |
| 2759 | '("^[ \t]*| *\\([#!$*_^]\\) *|" (1 'org-formula t)) | 3034 | '("^[ \t]*| *\\([#!$*_^]\\) *|" (1 'org-formula t)) |
| @@ -2795,7 +3070,11 @@ between words." | |||
| 2795 | ;;; Visibility cycling | 3070 | ;;; Visibility cycling |
| 2796 | 3071 | ||
| 2797 | (defvar org-cycle-global-status nil) | 3072 | (defvar org-cycle-global-status nil) |
| 3073 | (make-variable-buffer-local 'org-cycle-global-status) | ||
| 2798 | (defvar org-cycle-subtree-status nil) | 3074 | (defvar org-cycle-subtree-status nil) |
| 3075 | (make-variable-buffer-local 'org-cycle-subtree-status) | ||
| 3076 | |||
| 3077 | ;;;###autoload | ||
| 2799 | (defun org-cycle (&optional arg) | 3078 | (defun org-cycle (&optional arg) |
| 2800 | "Visibility cycling for Org-mode. | 3079 | "Visibility cycling for Org-mode. |
| 2801 | 3080 | ||
| @@ -2825,15 +3104,17 @@ between words." | |||
| 2825 | no headline in line 1, this function will act as if called with prefix arg." | 3104 | no headline in line 1, this function will act as if called with prefix arg." |
| 2826 | (interactive "P") | 3105 | (interactive "P") |
| 2827 | 3106 | ||
| 2828 | (if (or (and (bobp) (not (looking-at outline-regexp))) | 3107 | (let* ((outline-regexp |
| 2829 | (equal arg '(4))) | 3108 | (if org-cycle-include-plain-lists |
| 2830 | ;; special case: use global cycling | 3109 | "\\*+\\|\\([ \t]*\\)\\([-+*]\\|[0-9]+[.)]\\) " |
| 2831 | (setq arg t)) | 3110 | outline-regexp)) |
| 3111 | (bob-special (and org-cycle-global-at-bob (bobp) | ||
| 3112 | (not (looking-at outline-regexp)))) | ||
| 3113 | (org-cycle-hook (if bob-special nil org-cycle-hook))) | ||
| 2832 | 3114 | ||
| 2833 | (let ((outline-regexp | 3115 | (if (or bob-special (equal arg '(4))) |
| 2834 | (if org-cycle-include-plain-lists | 3116 | ;; special case: use global cycling |
| 2835 | "\\*+\\|\\([ \t]*\\)\\([-+*]\\|[0-9]+[.)]\\) " | 3117 | (setq arg t)) |
| 2836 | outline-regexp))) | ||
| 2837 | 3118 | ||
| 2838 | (cond | 3119 | (cond |
| 2839 | 3120 | ||
| @@ -2843,7 +3124,7 @@ between words." | |||
| 2843 | (progn | 3124 | (progn |
| 2844 | (if arg (org-table-edit-field t) | 3125 | (if arg (org-table-edit-field t) |
| 2845 | (org-table-justify-field-maybe) | 3126 | (org-table-justify-field-maybe) |
| 2846 | (org-table-next-field))))) | 3127 | (call-interactively 'org-table-next-field))))) |
| 2847 | 3128 | ||
| 2848 | ((eq arg t) ;; Global cycling | 3129 | ((eq arg t) ;; Global cycling |
| 2849 | 3130 | ||
| @@ -2853,18 +3134,8 @@ between words." | |||
| 2853 | ;; We just created the overview - now do table of contents | 3134 | ;; We just created the overview - now do table of contents |
| 2854 | ;; This can be slow in very large buffers, so indicate action | 3135 | ;; This can be slow in very large buffers, so indicate action |
| 2855 | (message "CONTENTS...") | 3136 | (message "CONTENTS...") |
| 2856 | (save-excursion | 3137 | (org-content) |
| 2857 | ;; Visit all headings and show their offspring | 3138 | (message "CONTENTS...done") |
| 2858 | (goto-char (point-max)) | ||
| 2859 | (catch 'exit | ||
| 2860 | (while (and (progn (condition-case nil | ||
| 2861 | (outline-previous-visible-heading 1) | ||
| 2862 | (error (goto-char (point-min)))) | ||
| 2863 | t) | ||
| 2864 | (looking-at outline-regexp)) | ||
| 2865 | (show-branches) | ||
| 2866 | (if (bobp) (throw 'exit nil)))) | ||
| 2867 | (message "CONTENTS...done")) | ||
| 2868 | (setq org-cycle-global-status 'contents) | 3139 | (setq org-cycle-global-status 'contents) |
| 2869 | (run-hook-with-args 'org-cycle-hook 'contents)) | 3140 | (run-hook-with-args 'org-cycle-hook 'contents)) |
| 2870 | 3141 | ||
| @@ -2878,7 +3149,7 @@ between words." | |||
| 2878 | 3149 | ||
| 2879 | (t | 3150 | (t |
| 2880 | ;; Default action: go to overview | 3151 | ;; Default action: go to overview |
| 2881 | (hide-sublevels 1) | 3152 | (org-overview) |
| 2882 | (message "OVERVIEW") | 3153 | (message "OVERVIEW") |
| 2883 | (setq org-cycle-global-status 'overview) | 3154 | (setq org-cycle-global-status 'overview) |
| 2884 | (run-hook-with-args 'org-cycle-hook 'overview)))) | 3155 | (run-hook-with-args 'org-cycle-hook 'overview)))) |
| @@ -2908,10 +3179,10 @@ between words." | |||
| 2908 | (outline-next-heading)) | 3179 | (outline-next-heading)) |
| 2909 | ;; Find out what to do next and set `this-command' | 3180 | ;; Find out what to do next and set `this-command' |
| 2910 | (cond | 3181 | (cond |
| 2911 | ((= eos eoh) | 3182 | ((and (= eos eoh) |
| 2912 | ;; Nothing is hidden behind this heading | 3183 | ;; Nothing is hidden behind this heading |
| 2913 | (message "EMPTY ENTRY") | 3184 | (message "EMPTY ENTRY") |
| 2914 | (setq org-cycle-subtree-status nil)) | 3185 | (setq org-cycle-subtree-status nil))) |
| 2915 | ((>= eol eos) | 3186 | ((>= eol eos) |
| 2916 | ;; Entire subtree is hidden in one line: open it | 3187 | ;; Entire subtree is hidden in one line: open it |
| 2917 | (org-show-entry) | 3188 | (org-show-entry) |
| @@ -2951,6 +3222,44 @@ between words." | |||
| 2951 | (org-back-to-heading) | 3222 | (org-back-to-heading) |
| 2952 | (org-cycle)))))) | 3223 | (org-cycle)))))) |
| 2953 | 3224 | ||
| 3225 | ;;;###autoload | ||
| 3226 | (defun org-global-cycle () | ||
| 3227 | "Cycle the global visibility. For details see `org-cycle'." | ||
| 3228 | (interactive) | ||
| 3229 | (org-cycle '(4))) | ||
| 3230 | |||
| 3231 | (defun org-overview () | ||
| 3232 | "Switch to overview mode, shoing only top-level headlines. | ||
| 3233 | Really, this shows all headlines with level equal or greater than the level | ||
| 3234 | of the first headline in the buffer. This is important, because if the | ||
| 3235 | first headline is not level one, then (hide-sublevels 1) gives confusing | ||
| 3236 | results." | ||
| 3237 | (interactive) | ||
| 3238 | (hide-sublevels (save-excursion | ||
| 3239 | (goto-char (point-min)) | ||
| 3240 | (if (re-search-forward (concat "^" outline-regexp) nil t) | ||
| 3241 | (progn | ||
| 3242 | (goto-char (match-beginning 0)) | ||
| 3243 | (funcall outline-level)) | ||
| 3244 | 1)))) | ||
| 3245 | |||
| 3246 | ;; FIXME: allow an argument to give a limiting level for this. | ||
| 3247 | (defun org-content () | ||
| 3248 | "Show all headlines in the buffer, like a table of contents" | ||
| 3249 | (interactive) | ||
| 3250 | (save-excursion | ||
| 3251 | ;; Visit all headings and show their offspring | ||
| 3252 | (goto-char (point-max)) | ||
| 3253 | (catch 'exit | ||
| 3254 | (while (and (progn (condition-case nil | ||
| 3255 | (outline-previous-visible-heading 1) | ||
| 3256 | (error (goto-char (point-min)))) | ||
| 3257 | t) | ||
| 3258 | (looking-at outline-regexp)) | ||
| 3259 | (show-branches) | ||
| 3260 | (if (bobp) (throw 'exit nil)))))) | ||
| 3261 | |||
| 3262 | |||
| 2954 | (defun org-optimize-window-after-visibility-change (state) | 3263 | (defun org-optimize-window-after-visibility-change (state) |
| 2955 | "Adjust the window after a change in outline visibility. | 3264 | "Adjust the window after a change in outline visibility. |
| 2956 | This function is the default value of the hook `org-cycle-hook'." | 3265 | This function is the default value of the hook `org-cycle-hook'." |
| @@ -3071,7 +3380,6 @@ or nil." | |||
| 3071 | (kill-buffer "*org-goto*") | 3380 | (kill-buffer "*org-goto*") |
| 3072 | org-selected-point)) | 3381 | org-selected-point)) |
| 3073 | 3382 | ||
| 3074 | ;; FIXME: It may not be a good idea to temper with the prefix argument... | ||
| 3075 | (defun org-goto-ret (&optional arg) | 3383 | (defun org-goto-ret (&optional arg) |
| 3076 | "Finish `org-goto' by going to the new location." | 3384 | "Finish `org-goto' by going to the new location." |
| 3077 | (interactive "P") | 3385 | (interactive "P") |
| @@ -3114,26 +3422,36 @@ or nil." | |||
| 3114 | "To temporarily disable the active region.") | 3422 | "To temporarily disable the active region.") |
| 3115 | 3423 | ||
| 3116 | (defun org-insert-heading (&optional force-heading) | 3424 | (defun org-insert-heading (&optional force-heading) |
| 3117 | "Insert a new heading or item with same depth at point." | 3425 | "Insert a new heading or item with same depth at point. |
| 3426 | If point is in a plain list and FORCE-HEADING is nil, create a new list item. | ||
| 3427 | If point is at the beginning of a headline, insert a sibling before the | ||
| 3428 | current headline. If point is in the middle of a headline, split the headline | ||
| 3429 | at that position and make the rest of the headline part of the sibling below | ||
| 3430 | the current headline." | ||
| 3118 | (interactive "P") | 3431 | (interactive "P") |
| 3119 | (when (or force-heading (not (org-insert-item))) | 3432 | (if (= (buffer-size) 0) |
| 3120 | (let* ((head (save-excursion | 3433 | (insert "\n* ") |
| 3121 | (condition-case nil | 3434 | (when (or force-heading (not (org-insert-item))) |
| 3122 | (org-back-to-heading) | 3435 | (let* ((head (save-excursion |
| 3123 | (error (outline-next-heading))) | 3436 | (condition-case nil |
| 3124 | (prog1 (match-string 0) | 3437 | (progn |
| 3125 | (funcall outline-level))))) | 3438 | (org-back-to-heading) |
| 3126 | (cond | 3439 | (match-string 0)) |
| 3127 | ((and (org-on-heading-p) (bolp) | 3440 | (error "*")))) |
| 3128 | (save-excursion (backward-char 1) (not (org-invisible-p)))) | 3441 | pos) |
| 3129 | (open-line 1)) | 3442 | (cond |
| 3130 | ((bolp) nil) | 3443 | ((and (org-on-heading-p) (bolp) |
| 3131 | (t (newline))) | 3444 | (save-excursion (backward-char 1) (not (org-invisible-p)))) |
| 3132 | (insert head) | 3445 | (open-line 1)) |
| 3133 | (just-one-space) | 3446 | ((bolp) nil) |
| 3134 | (run-hooks 'org-insert-heading-hook)))) | 3447 | (t (newline))) |
| 3135 | 3448 | (insert head) (just-one-space) | |
| 3136 | (defun org-insert-item () | 3449 | (setq pos (point)) |
| 3450 | (end-of-line 1) | ||
| 3451 | (unless (= (point) pos) (just-one-space) (backward-delete-char 1)) | ||
| 3452 | (run-hooks 'org-insert-heading-hook))))) | ||
| 3453 | |||
| 3454 | (defun org-insert-item (&optional checkbox) | ||
| 3137 | "Insert a new item at the current level. | 3455 | "Insert a new item at the current level. |
| 3138 | Return t when things worked, nil when we are not in an item." | 3456 | Return t when things worked, nil when we are not in an item." |
| 3139 | (when (save-excursion | 3457 | (when (save-excursion |
| @@ -3144,9 +3462,11 @@ Return t when things worked, nil when we are not in an item." | |||
| 3144 | t) | 3462 | t) |
| 3145 | (error nil))) | 3463 | (error nil))) |
| 3146 | (let* ((bul (match-string 0)) | 3464 | (let* ((bul (match-string 0)) |
| 3465 | (end (match-end 0)) | ||
| 3147 | (eow (save-excursion (beginning-of-line 1) (looking-at "[ \t]*") | 3466 | (eow (save-excursion (beginning-of-line 1) (looking-at "[ \t]*") |
| 3148 | (match-end 0))) | 3467 | (match-end 0))) |
| 3149 | (eowcol (save-excursion (goto-char eow) (current-column)))) | 3468 | (eowcol (save-excursion (goto-char eow) (current-column))) |
| 3469 | pos) | ||
| 3150 | (cond | 3470 | (cond |
| 3151 | ((and (org-at-item-p) (<= (point) eow)) | 3471 | ((and (org-at-item-p) (<= (point) eow)) |
| 3152 | ;; before the bullet | 3472 | ;; before the bullet |
| @@ -3155,8 +3475,11 @@ Return t when things worked, nil when we are not in an item." | |||
| 3155 | ((<= (point) eow) | 3475 | ((<= (point) eow) |
| 3156 | (beginning-of-line 1)) | 3476 | (beginning-of-line 1)) |
| 3157 | (t (newline))) | 3477 | (t (newline))) |
| 3158 | (insert bul) | 3478 | (insert bul (if checkbox "[ ]" "")) |
| 3159 | (just-one-space)) | 3479 | (just-one-space) |
| 3480 | (setq pos (point)) | ||
| 3481 | (end-of-line 1) | ||
| 3482 | (unless (= (point) pos) (just-one-space) (backward-delete-char 1))) | ||
| 3160 | (org-maybe-renumber-ordered-list) | 3483 | (org-maybe-renumber-ordered-list) |
| 3161 | t)) | 3484 | t)) |
| 3162 | 3485 | ||
| @@ -3165,16 +3488,19 @@ Return t when things worked, nil when we are not in an item." | |||
| 3165 | If the heading has no TODO state, or if the state is DONE, use the first | 3488 | If the heading has no TODO state, or if the state is DONE, use the first |
| 3166 | state (TODO by default). Also with prefix arg, force first state." | 3489 | state (TODO by default). Also with prefix arg, force first state." |
| 3167 | (interactive "P") | 3490 | (interactive "P") |
| 3168 | (org-insert-heading) | 3491 | (when (not (org-insert-item 'checkbox)) |
| 3169 | (save-excursion | 3492 | (org-insert-heading) |
| 3170 | (org-back-to-heading) | 3493 | (save-excursion |
| 3171 | (outline-previous-heading) | 3494 | (org-back-to-heading) |
| 3172 | (looking-at org-todo-line-regexp)) | 3495 | (if org-noutline-p |
| 3173 | (if (or arg | 3496 | (outline-previous-heading) |
| 3174 | (not (match-beginning 2)) | 3497 | (outline-previous-visible-heading t)) |
| 3175 | (equal (match-string 2) org-done-string)) | 3498 | (looking-at org-todo-line-regexp)) |
| 3176 | (insert (car org-todo-keywords) " ") | 3499 | (if (or arg |
| 3177 | (insert (match-string 2) " "))) | 3500 | (not (match-beginning 2)) |
| 3501 | (equal (match-string 2) org-done-string)) | ||
| 3502 | (insert (car org-todo-keywords) " ") | ||
| 3503 | (insert (match-string 2) " ")))) | ||
| 3178 | 3504 | ||
| 3179 | (defun org-promote-subtree () | 3505 | (defun org-promote-subtree () |
| 3180 | "Promote the entire subtree. | 3506 | "Promote the entire subtree. |
| @@ -3510,6 +3836,21 @@ If optional TXT is given, check this string instead of the current kill." | |||
| 3510 | ((= llt ?\)) "\\([ \t]*\\([-+]\\|\\([0-9]+)\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)") | 3836 | ((= llt ?\)) "\\([ \t]*\\([-+]\\|\\([0-9]+)\\)\\)\\|[ \t]+\\*\\)\\( \\|$\\)") |
| 3511 | (t (error "Invalid value of `org-plain-list-ordered-item-terminator'"))))))) | 3837 | (t (error "Invalid value of `org-plain-list-ordered-item-terminator'"))))))) |
| 3512 | 3838 | ||
| 3839 | (defun org-at-item-checkbox-p () | ||
| 3840 | "Is point at a line starting a plain-list item with a checklet?" | ||
| 3841 | (and (org-at-item-p) | ||
| 3842 | (save-excursion | ||
| 3843 | (goto-char (match-end 0)) | ||
| 3844 | (skip-chars-forward " \t") | ||
| 3845 | (looking-at "\\[[ X]\\]")))) | ||
| 3846 | |||
| 3847 | (defun org-toggle-checkbox () | ||
| 3848 | "Toggle the checkbox in the current line." | ||
| 3849 | (interactive) | ||
| 3850 | (save-excursion | ||
| 3851 | (if (org-at-item-checkbox-p) | ||
| 3852 | (replace-match (if (equal (match-string 0) "[ ]") "[X]" "[ ]") t t)))) | ||
| 3853 | |||
| 3513 | (defun org-get-indentation () | 3854 | (defun org-get-indentation () |
| 3514 | "Get the indentation of the current line, interpreting tabs." | 3855 | "Get the indentation of the current line, interpreting tabs." |
| 3515 | (save-excursion | 3856 | (save-excursion |
| @@ -3520,6 +3861,7 @@ If optional TXT is given, check this string instead of the current kill." | |||
| 3520 | (defun org-beginning-of-item () | 3861 | (defun org-beginning-of-item () |
| 3521 | "Go to the beginning of the current hand-formatted item. | 3862 | "Go to the beginning of the current hand-formatted item. |
| 3522 | If the cursor is not in an item, throw an error." | 3863 | If the cursor is not in an item, throw an error." |
| 3864 | (interactive) | ||
| 3523 | (let ((pos (point)) | 3865 | (let ((pos (point)) |
| 3524 | (limit (save-excursion (org-back-to-heading) | 3866 | (limit (save-excursion (org-back-to-heading) |
| 3525 | (beginning-of-line 2) (point))) | 3867 | (beginning-of-line 2) (point))) |
| @@ -3545,6 +3887,7 @@ If the cursor is not in an item, throw an error." | |||
| 3545 | (defun org-end-of-item () | 3887 | (defun org-end-of-item () |
| 3546 | "Go to the end of the current hand-formatted item. | 3888 | "Go to the end of the current hand-formatted item. |
| 3547 | If the cursor is not in an item, throw an error." | 3889 | If the cursor is not in an item, throw an error." |
| 3890 | (interactive) | ||
| 3548 | (let ((pos (point)) | 3891 | (let ((pos (point)) |
| 3549 | (limit (save-excursion (outline-next-heading) (point))) | 3892 | (limit (save-excursion (outline-next-heading) (point))) |
| 3550 | (ind (save-excursion | 3893 | (ind (save-excursion |
| @@ -3564,11 +3907,47 @@ If the cursor is not in an item, throw an error." | |||
| 3564 | (goto-char pos) | 3907 | (goto-char pos) |
| 3565 | (error "Not in an item")))) | 3908 | (error "Not in an item")))) |
| 3566 | 3909 | ||
| 3567 | (defun org-move-item-down (arg) | 3910 | (defun org-next-item () |
| 3911 | "Move to the beginning of the next item in the current plain list. | ||
| 3912 | Error if not at a plain list, or if this is the last item in the list." | ||
| 3913 | (interactive) | ||
| 3914 | (let (beg end ind ind1 (pos (point)) txt) | ||
| 3915 | (org-beginning-of-item) | ||
| 3916 | (setq beg (point)) | ||
| 3917 | (setq ind (org-get-indentation)) | ||
| 3918 | (org-end-of-item) | ||
| 3919 | (setq end (point)) | ||
| 3920 | (setq ind1 (org-get-indentation)) | ||
| 3921 | (unless (and (org-at-item-p) (= ind ind1)) | ||
| 3922 | (goto-char pos) | ||
| 3923 | (error "This is already the last item in the list")))) | ||
| 3924 | |||
| 3925 | (defun org-previous-item () | ||
| 3926 | "Move to the beginning of the previous item in the current plain list. | ||
| 3927 | Error if not at a plain list, or if this is the last item in the list." | ||
| 3928 | (interactive) | ||
| 3929 | (let (beg end ind ind1 (pos (point)) txt) | ||
| 3930 | (org-beginning-of-item) | ||
| 3931 | (setq beg (point)) | ||
| 3932 | (setq ind (org-get-indentation)) | ||
| 3933 | (goto-char beg) | ||
| 3934 | (catch 'exit | ||
| 3935 | (while t | ||
| 3936 | (beginning-of-line 0) | ||
| 3937 | (if (looking-at "[ \t]*$") | ||
| 3938 | nil | ||
| 3939 | (if (<= (setq ind1 (org-get-indentation)) ind) | ||
| 3940 | (throw 'exit t))))) | ||
| 3941 | (condition-case nil | ||
| 3942 | (org-beginning-of-item) | ||
| 3943 | (error (goto-char pos) | ||
| 3944 | (error "This is already the first item in the list"))))) | ||
| 3945 | |||
| 3946 | (defun org-move-item-down () | ||
| 3568 | "Move the plain list item at point down, i.e. swap with following item. | 3947 | "Move the plain list item at point down, i.e. swap with following item. |
| 3569 | Subitems (items with larger indentation) are considered part of the item, | 3948 | Subitems (items with larger indentation) are considered part of the item, |
| 3570 | so this really moves item trees." | 3949 | so this really moves item trees." |
| 3571 | (interactive "p") | 3950 | (interactive) |
| 3572 | (let (beg end ind ind1 (pos (point)) txt) | 3951 | (let (beg end ind ind1 (pos (point)) txt) |
| 3573 | (org-beginning-of-item) | 3952 | (org-beginning-of-item) |
| 3574 | (setq beg (point)) | 3953 | (setq beg (point)) |
| @@ -3647,7 +4026,7 @@ doing the renumbering." | |||
| 3647 | 4026 | ||
| 3648 | (defun org-renumber-ordered-list (arg) | 4027 | (defun org-renumber-ordered-list (arg) |
| 3649 | "Renumber an ordered plain list. | 4028 | "Renumber an ordered plain list. |
| 3650 | Cursor next to be in the first line of an item, the line that starts | 4029 | Cursor needs to be in the first line of an item, the line that starts |
| 3651 | with something like \"1.\" or \"2)\"." | 4030 | with something like \"1.\" or \"2)\"." |
| 3652 | (interactive "p") | 4031 | (interactive "p") |
| 3653 | (unless (and (org-at-item-p) | 4032 | (unless (and (org-at-item-p) |
| @@ -3702,24 +4081,24 @@ with something like \"1.\" or \"2)\"." | |||
| 3702 | (interactive "p") | 4081 | (interactive "p") |
| 3703 | (unless (org-at-item-p) | 4082 | (unless (org-at-item-p) |
| 3704 | (error "Not on an item")) | 4083 | (error "Not on an item")) |
| 3705 | (let (beg end ind ind1) | 4084 | (save-excursion |
| 3706 | (if (memq last-command '(org-shiftmetaright org-shiftmetaleft)) | 4085 | (let (beg end ind ind1) |
| 4086 | (if (memq last-command '(org-shiftmetaright org-shiftmetaleft)) | ||
| 3707 | (setq beg org-last-indent-begin-marker | 4087 | (setq beg org-last-indent-begin-marker |
| 3708 | end org-last-indent-end-marker) | 4088 | end org-last-indent-end-marker) |
| 3709 | (org-beginning-of-item) | 4089 | (org-beginning-of-item) |
| 3710 | (setq beg (move-marker org-last-indent-begin-marker (point))) | 4090 | (setq beg (move-marker org-last-indent-begin-marker (point))) |
| 3711 | (org-end-of-item) | 4091 | (org-end-of-item) |
| 3712 | (setq end (move-marker org-last-indent-end-marker (point)))) | 4092 | (setq end (move-marker org-last-indent-end-marker (point)))) |
| 3713 | (goto-char beg) | 4093 | (goto-char beg) |
| 3714 | (skip-chars-forward " \t") (setq ind (current-column)) | 4094 | (skip-chars-forward " \t") (setq ind (current-column)) |
| 3715 | (if (< (+ arg ind) 0) (error "Cannot outdent beyond margin")) | 4095 | (if (< (+ arg ind) 0) (error "Cannot outdent beyond margin")) |
| 3716 | (while (< (point) end) | 4096 | (while (< (point) end) |
| 3717 | (beginning-of-line 1) | 4097 | (beginning-of-line 1) |
| 3718 | (skip-chars-forward " \t") (setq ind1 (current-column)) | 4098 | (skip-chars-forward " \t") (setq ind1 (current-column)) |
| 3719 | (delete-region (point-at-bol) (point)) | 4099 | (delete-region (point-at-bol) (point)) |
| 3720 | (indent-to-column (+ ind1 arg)) | 4100 | (indent-to-column (+ ind1 arg)) |
| 3721 | (beginning-of-line 2)) | 4101 | (beginning-of-line 2))))) |
| 3722 | (goto-char beg))) | ||
| 3723 | 4102 | ||
| 3724 | ;;; Archiving | 4103 | ;;; Archiving |
| 3725 | 4104 | ||
| @@ -3816,7 +4195,7 @@ heading be marked DONE, and the current time will be added." | |||
| 3816 | ;; Here we are back in the original buffer. Everything seems to have | 4195 | ;; Here we are back in the original buffer. Everything seems to have |
| 3817 | ;; worked. So now cut the tree and finish up. | 4196 | ;; worked. So now cut the tree and finish up. |
| 3818 | (let (this-command) (org-cut-subtree)) | 4197 | (let (this-command) (org-cut-subtree)) |
| 3819 | (if (looking-at "[ \t]*$") (kill-line)) | 4198 | (if (and (not (eobp)) (looking-at "[ \t]*$")) (kill-line)) |
| 3820 | (message "Subtree archived %s" | 4199 | (message "Subtree archived %s" |
| 3821 | (if (eq this-buffer buffer) | 4200 | (if (eq this-buffer buffer) |
| 3822 | (concat "under heading: " heading) | 4201 | (concat "under heading: " heading) |
| @@ -3880,7 +4259,7 @@ At all other locations, this simply calls `ispell-complete-word'." | |||
| 3880 | tbl))) | 4259 | tbl))) |
| 3881 | tbl) | 4260 | tbl) |
| 3882 | (tag (setq type :tag beg beg1) | 4261 | (tag (setq type :tag beg beg1) |
| 3883 | (org-get-buffer-tags)) | 4262 | (or org-tag-alist (org-get-buffer-tags))) |
| 3884 | (t (progn (ispell-complete-word arg) (throw 'exit nil))))) | 4263 | (t (progn (ispell-complete-word arg) (throw 'exit nil))))) |
| 3885 | (pattern (buffer-substring-no-properties beg end)) | 4264 | (pattern (buffer-substring-no-properties beg end)) |
| 3886 | (completion (try-completion pattern table))) | 4265 | (completion (try-completion pattern table))) |
| @@ -3960,44 +4339,44 @@ prefix arg, switch to that state." | |||
| 3960 | (member (member this org-todo-keywords)) | 4339 | (member (member this org-todo-keywords)) |
| 3961 | (tail (cdr member)) | 4340 | (tail (cdr member)) |
| 3962 | (state (cond | 4341 | (state (cond |
| 3963 | ((equal arg '(4)) | 4342 | ((equal arg '(4)) |
| 3964 | ;; Read a state with completion | 4343 | ;; Read a state with completion |
| 3965 | (completing-read "State: " (mapcar (lambda(x) (list x)) | 4344 | (completing-read "State: " (mapcar (lambda(x) (list x)) |
| 3966 | org-todo-keywords) | 4345 | org-todo-keywords) |
| 3967 | nil t)) | 4346 | nil t)) |
| 3968 | ((eq arg 'right) | 4347 | ((eq arg 'right) |
| 3969 | (if this | 4348 | (if this |
| 3970 | (if tail (car tail) nil) | 4349 | (if tail (car tail) nil) |
| 3971 | (car org-todo-keywords))) | 4350 | (car org-todo-keywords))) |
| 3972 | ((eq arg 'left) | 4351 | ((eq arg 'left) |
| 3973 | (if (equal member org-todo-keywords) | 4352 | (if (equal member org-todo-keywords) |
| 3974 | nil | 4353 | nil |
| 3975 | (if this | 4354 | (if this |
| 3976 | (nth (- (length org-todo-keywords) (length tail) 2) | 4355 | (nth (- (length org-todo-keywords) (length tail) 2) |
| 3977 | org-todo-keywords) | 4356 | org-todo-keywords) |
| 3978 | org-done-string))) | 4357 | org-done-string))) |
| 3979 | (arg | 4358 | (arg |
| 3980 | ;; user requests a specific state | 4359 | ;; user requests a specific state |
| 3981 | (nth (1- (prefix-numeric-value arg)) | 4360 | (nth (1- (prefix-numeric-value arg)) |
| 3982 | org-todo-keywords)) | 4361 | org-todo-keywords)) |
| 3983 | ((null member) (car org-todo-keywords)) | 4362 | ((null member) (car org-todo-keywords)) |
| 3984 | ((null tail) nil) ;; -> first entry | 4363 | ((null tail) nil) ;; -> first entry |
| 3985 | ((eq org-todo-interpretation 'sequence) | 4364 | ((eq org-todo-interpretation 'sequence) |
| 3986 | (car tail)) | 4365 | (car tail)) |
| 3987 | ((memq org-todo-interpretation '(type priority)) | 4366 | ((memq org-todo-interpretation '(type priority)) |
| 3988 | (if (eq this-command last-command) | 4367 | (if (eq this-command last-command) |
| 3989 | (car tail) | 4368 | (car tail) |
| 3990 | (if (> (length tail) 0) org-done-string nil))) | 4369 | (if (> (length tail) 0) org-done-string nil))) |
| 3991 | (t nil))) | 4370 | (t nil))) |
| 3992 | (next (if state (concat " " state " ") " "))) | 4371 | (next (if state (concat " " state " ") " "))) |
| 3993 | (replace-match next t t) | 4372 | (replace-match next t t) |
| 3994 | (setq org-last-todo-state-is-todo | 4373 | (setq org-last-todo-state-is-todo |
| 3995 | (not (equal state org-done-string))) | 4374 | (not (equal state org-done-string))) |
| 3996 | (when org-log-done | 4375 | (when org-log-done |
| 3997 | (if (equal state org-done-string) | 4376 | (if (equal state org-done-string) |
| 3998 | (org-log-done) | 4377 | (org-add-planning-info 'closed (current-time) 'scheduled) |
| 3999 | (if (not this) | 4378 | (if (not this) |
| 4000 | (org-log-done t)))) | 4379 | (org-add-planning-info nil nil 'closed)))) |
| 4001 | ;; Fixup tag positioning | 4380 | ;; Fixup tag positioning |
| 4002 | (and org-auto-align-tags (org-set-tags nil t)) | 4381 | (and org-auto-align-tags (org-set-tags nil t)) |
| 4003 | (run-hooks 'org-after-todo-state-change-hook))) | 4382 | (run-hooks 'org-after-todo-state-change-hook))) |
| @@ -4067,25 +4446,79 @@ of `org-todo-keywords'." | |||
| 4067 | A timestamp is also inserted - use \\[org-timestamp-up] and \\[org-timestamp-down] | 4446 | A timestamp is also inserted - use \\[org-timestamp-up] and \\[org-timestamp-down] |
| 4068 | to modify it to the correct date." | 4447 | to modify it to the correct date." |
| 4069 | (interactive) | 4448 | (interactive) |
| 4070 | (insert | 4449 | (org-add-planning-info 'deadline nil 'closed)) |
| 4071 | org-deadline-string " " | ||
| 4072 | (format-time-string (car org-time-stamp-formats) | ||
| 4073 | (org-read-date nil 'to-time))) | ||
| 4074 | (message "%s" (substitute-command-keys | ||
| 4075 | "Use \\[org-timestamp-up-day] and \\[org-timestamp-down-day] to change the date."))) | ||
| 4076 | 4450 | ||
| 4077 | (defun org-schedule () | 4451 | (defun org-schedule () |
| 4078 | "Insert the SCHEDULED: string to schedule a TODO item. | 4452 | "Insert the SCHEDULED: string to schedule a TODO item. |
| 4079 | A timestamp is also inserted - use \\[org-timestamp-up] and \\[org-timestamp-down] | 4453 | A timestamp is also inserted - use \\[org-timestamp-up] and \\[org-timestamp-down] |
| 4080 | to modify it to the correct date." | 4454 | to modify it to the correct date." |
| 4081 | (interactive) | 4455 | (interactive) |
| 4082 | (insert | 4456 | (org-add-planning-info 'scheduled nil 'closed)) |
| 4083 | org-scheduled-string " " | 4457 | |
| 4084 | (format-time-string (car org-time-stamp-formats) | 4458 | (defun org-add-planning-info (what &optional time &rest remove) |
| 4085 | (org-read-date nil 'to-time))) | 4459 | "Insert new timestamp with keyword in the line directly after the headline. |
| 4086 | (message "%s" (substitute-command-keys | 4460 | WHAT indicates what kind of time stamp to add. TIME indicated the time to use. |
| 4087 | "Use \\[org-timestamp-up-day] and \\[org-timestamp-down-day] to change the date."))) | 4461 | If non is given, the user is prompted for a date. |
| 4088 | 4462 | REMOVE indicates what kind of entries to remove. An old WHAT entry will also | |
| 4463 | be removed." | ||
| 4464 | (interactive) | ||
| 4465 | (when what (setq time (or time (org-read-date nil 'to-time)))) | ||
| 4466 | (when (and org-insert-labeled-timestamps-at-point | ||
| 4467 | (member what '(scheduled deadline))) | ||
| 4468 | (insert | ||
| 4469 | (if (eq what 'scheduled) org-scheduled-string org-deadline-string) | ||
| 4470 | " " | ||
| 4471 | (format-time-string (car org-time-stamp-formats) time)) | ||
| 4472 | (setq what nil)) | ||
| 4473 | (save-excursion | ||
| 4474 | (let (beg end col list elt (buffer-invisibility-spec nil) ts) | ||
| 4475 | (org-back-to-heading t) | ||
| 4476 | (setq beg (point)) | ||
| 4477 | (looking-at (concat outline-regexp "\\( *\\)[^\r\n]*")) | ||
| 4478 | (goto-char (match-end 1)) | ||
| 4479 | (setq col (current-column)) | ||
| 4480 | (goto-char (1+ (match-end 0))) | ||
| 4481 | (if (and (not (looking-at outline-regexp)) | ||
| 4482 | (looking-at (concat "[^\r\n]*?" org-keyword-time-regexp | ||
| 4483 | "[^\r\n]*"))) | ||
| 4484 | (narrow-to-region (match-beginning 0) (match-end 0)) | ||
| 4485 | (insert "\n") | ||
| 4486 | (backward-char 1) | ||
| 4487 | (narrow-to-region (point) (point)) | ||
| 4488 | (indent-to-column col)) | ||
| 4489 | ;; Check if we have to remove something. | ||
| 4490 | (setq list (cons what remove)) | ||
| 4491 | (while list | ||
| 4492 | (setq elt (pop list)) | ||
| 4493 | (goto-char (point-min)) | ||
| 4494 | (when (or (and (eq elt 'scheduled) | ||
| 4495 | (re-search-forward org-scheduled-time-regexp nil t)) | ||
| 4496 | (and (eq elt 'deadline) | ||
| 4497 | (re-search-forward org-deadline-time-regexp nil t)) | ||
| 4498 | (and (eq elt 'closed) | ||
| 4499 | (re-search-forward org-closed-time-regexp nil t))) | ||
| 4500 | (replace-match "") | ||
| 4501 | (if (looking-at " +") (replace-match "")))) | ||
| 4502 | (goto-char (point-max)) | ||
| 4503 | (when what | ||
| 4504 | (insert | ||
| 4505 | (if (not (equal (char-before) ?\ )) " " "") | ||
| 4506 | (cond ((eq what 'scheduled) org-scheduled-string) | ||
| 4507 | ((eq what 'deadline) org-deadline-string) | ||
| 4508 | ((eq what 'closed) org-closed-string)) | ||
| 4509 | " ") | ||
| 4510 | (insert | ||
| 4511 | (setq ts | ||
| 4512 | (format-time-string | ||
| 4513 | (if (eq what 'closed) | ||
| 4514 | (concat "[" (substring (cdr org-time-stamp-formats) 1 -1) "]") | ||
| 4515 | (car org-time-stamp-formats)) | ||
| 4516 | time)))) | ||
| 4517 | (goto-char (point-min)) | ||
| 4518 | (widen) | ||
| 4519 | (if (looking-at "[ \t]+\r?\n") | ||
| 4520 | (replace-match "")) | ||
| 4521 | ts))) | ||
| 4089 | 4522 | ||
| 4090 | (defun org-occur (regexp &optional callback) | 4523 | (defun org-occur (regexp &optional callback) |
| 4091 | "Make a compact tree which shows all matches of REGEXP. | 4524 | "Make a compact tree which shows all matches of REGEXP. |
| @@ -4100,7 +4533,7 @@ that the match should indeed be shown." | |||
| 4100 | (let ((cnt 0)) | 4533 | (let ((cnt 0)) |
| 4101 | (save-excursion | 4534 | (save-excursion |
| 4102 | (goto-char (point-min)) | 4535 | (goto-char (point-min)) |
| 4103 | (hide-sublevels 1) | 4536 | (org-overview) |
| 4104 | (while (re-search-forward regexp nil t) | 4537 | (while (re-search-forward regexp nil t) |
| 4105 | (when (or (not callback) | 4538 | (when (or (not callback) |
| 4106 | (save-match-data (funcall callback))) | 4539 | (save-match-data (funcall callback))) |
| @@ -4348,8 +4781,8 @@ used to insert the time stamp into the buffer to include the time." | |||
| 4348 | (parse-time-string (match-string 1)))) | 4781 | (parse-time-string (match-string 1)))) |
| 4349 | ct)) | 4782 | ct)) |
| 4350 | (calendar-move-hook nil) | 4783 | (calendar-move-hook nil) |
| 4351 | (view-calendar-holidays-initially nil) | ||
| 4352 | (view-diary-entries-initially nil) | 4784 | (view-diary-entries-initially nil) |
| 4785 | (view-calendar-holidays-initially nil) | ||
| 4353 | (timestr (format-time-string | 4786 | (timestr (format-time-string |
| 4354 | (if with-time "%Y-%m-%d %H:%M" "%Y-%m-%d") default-time)) | 4787 | (if with-time "%Y-%m-%d %H:%M" "%Y-%m-%d") default-time)) |
| 4355 | (prompt (format "YYYY-MM-DD [%s]: " timestr)) | 4788 | (prompt (format "YYYY-MM-DD [%s]: " timestr)) |
| @@ -4761,7 +5194,6 @@ If there is already a time stamp at the cursor position, update it." | |||
| 4761 | (defvar org-agenda-type nil) | 5194 | (defvar org-agenda-type nil) |
| 4762 | (defvar org-agenda-force-single-file nil) | 5195 | (defvar org-agenda-force-single-file nil) |
| 4763 | 5196 | ||
| 4764 | ;;;###autoload | ||
| 4765 | (defun org-agenda-mode () | 5197 | (defun org-agenda-mode () |
| 4766 | "Mode for time-sorted view on action items in Org-mode files. | 5198 | "Mode for time-sorted view on action items in Org-mode files. |
| 4767 | 5199 | ||
| @@ -4778,7 +5210,7 @@ The following commands are available: | |||
| 4778 | (org-add-hook 'post-command-hook 'org-agenda-post-command-hook nil 'local) | 5210 | (org-add-hook 'post-command-hook 'org-agenda-post-command-hook nil 'local) |
| 4779 | (org-add-hook 'pre-command-hook 'org-unhighlight nil 'local) | 5211 | (org-add-hook 'pre-command-hook 'org-unhighlight nil 'local) |
| 4780 | (unless org-agenda-keep-modes | 5212 | (unless org-agenda-keep-modes |
| 4781 | (setq org-agenda-follow-mode nil | 5213 | (setq org-agenda-follow-mode org-agenda-start-with-follow-mode |
| 4782 | org-agenda-show-log nil)) | 5214 | org-agenda-show-log nil)) |
| 4783 | (easy-menu-change | 5215 | (easy-menu-change |
| 4784 | '("Agenda") "Agenda Files" | 5216 | '("Agenda") "Agenda Files" |
| @@ -4815,6 +5247,8 @@ The following commands are available: | |||
| 4815 | (define-key org-agenda-mode-map [?\C-c ?\C-x (left)] 'org-agenda-date-earlier) | 5247 | (define-key org-agenda-mode-map [?\C-c ?\C-x (left)] 'org-agenda-date-earlier) |
| 4816 | 5248 | ||
| 4817 | (define-key org-agenda-mode-map ">" 'org-agenda-date-prompt) | 5249 | (define-key org-agenda-mode-map ">" 'org-agenda-date-prompt) |
| 5250 | (define-key org-agenda-mode-map "\C-c\C-s" 'org-agenda-schedule) | ||
| 5251 | (define-key org-agenda-mode-map "\C-c\C-d" 'org-agenda-deadline) | ||
| 4818 | (let ((l '(1 2 3 4 5 6 7 8 9 0))) | 5252 | (let ((l '(1 2 3 4 5 6 7 8 9 0))) |
| 4819 | (while l (define-key org-agenda-mode-map | 5253 | (while l (define-key org-agenda-mode-map |
| 4820 | (int-to-string (pop l)) 'digit-argument))) | 5254 | (int-to-string (pop l)) 'digit-argument))) |
| @@ -4878,10 +5312,12 @@ The following commands are available: | |||
| 4878 | ("Tags" | 5312 | ("Tags" |
| 4879 | ["Show all Tags" org-agenda-show-tags t] | 5313 | ["Show all Tags" org-agenda-show-tags t] |
| 4880 | ["Set Tags" org-agenda-set-tags t]) | 5314 | ["Set Tags" org-agenda-set-tags t]) |
| 4881 | ("Reschedule" | 5315 | ("Schedule" |
| 5316 | ["Schedule" org-agenda-schedule t] | ||
| 5317 | ["Set Deadline" org-agenda-deadline t] | ||
| 5318 | "--" | ||
| 4882 | ["Reschedule +1 day" org-agenda-date-later (org-agenda-check-type nil 'agenda 'timeline)] | 5319 | ["Reschedule +1 day" org-agenda-date-later (org-agenda-check-type nil 'agenda 'timeline)] |
| 4883 | ["Reschedule -1 day" org-agenda-date-earlier (org-agenda-check-type nil 'agenda 'timeline)] | 5320 | ["Reschedule -1 day" org-agenda-date-earlier (org-agenda-check-type nil 'agenda 'timeline)] |
| 4884 | "--" | ||
| 4885 | ["Reschedule to ..." org-agenda-date-prompt (org-agenda-check-type nil 'agenda 'timeline)]) | 5321 | ["Reschedule to ..." org-agenda-date-prompt (org-agenda-check-type nil 'agenda 'timeline)]) |
| 4886 | ("Priority" | 5322 | ("Priority" |
| 4887 | ["Set Priority" org-agenda-priority t] | 5323 | ["Set Priority" org-agenda-priority t] |
| @@ -4991,18 +5427,16 @@ C Configure your own agenda commands") | |||
| 4991 | ((equal c ?C) (customize-variable 'org-agenda-custom-commands)) | 5427 | ((equal c ?C) (customize-variable 'org-agenda-custom-commands)) |
| 4992 | ((equal c ?a) (call-interactively 'org-agenda-list)) | 5428 | ((equal c ?a) (call-interactively 'org-agenda-list)) |
| 4993 | ((equal c ?t) (call-interactively 'org-todo-list)) | 5429 | ((equal c ?t) (call-interactively 'org-todo-list)) |
| 4994 | ((equal c ?T) | 5430 | ((equal c ?T) (org-call-with-arg 'org-todo-list (or arg '(4)))) |
| 4995 | (setq current-prefix-arg (or arg '(4))) | ||
| 4996 | (call-interactively 'org-todo-list)) | ||
| 4997 | ((equal c ?m) (call-interactively 'org-tags-view)) | 5431 | ((equal c ?m) (call-interactively 'org-tags-view)) |
| 4998 | ((equal c ?M) | 5432 | ((equal c ?M) (org-call-with-arg 'org-tags-view (or arg '(4)))) |
| 4999 | (setq current-prefix-arg (or arg '(4))) | ||
| 5000 | (call-interactively 'org-tags-view)) | ||
| 5001 | ((setq entry (assoc (char-to-string c) org-agenda-custom-commands)) | 5433 | ((setq entry (assoc (char-to-string c) org-agenda-custom-commands)) |
| 5002 | (setq type (nth 1 entry) string (nth 2 entry)) | 5434 | (setq type (nth 1 entry) string (nth 2 entry)) |
| 5003 | (cond | 5435 | (cond |
| 5004 | ((eq type 'tags) | 5436 | ((eq type 'tags) |
| 5005 | (org-tags-view current-prefix-arg string)) | 5437 | (org-tags-view current-prefix-arg string)) |
| 5438 | ((eq type 'tags-todo) | ||
| 5439 | (org-tags-view '(4) string)) | ||
| 5006 | ((eq type 'todo) | 5440 | ((eq type 'todo) |
| 5007 | (org-todo-list string)) | 5441 | (org-todo-list string)) |
| 5008 | ((eq type 'tags-tree) | 5442 | ((eq type 'tags-tree) |
| @@ -5432,7 +5866,7 @@ If ERROR is non-nil, throw an error, otherwise just return nil." | |||
| 5432 | (if (memq org-agenda-type types) | 5866 | (if (memq org-agenda-type types) |
| 5433 | t | 5867 | t |
| 5434 | (if error | 5868 | (if error |
| 5435 | (error "Now allowed in %s-type agenda buffers" org-agenda-type) | 5869 | (error "Not allowed in %s-type agenda buffers" org-agenda-type) |
| 5436 | nil))) | 5870 | nil))) |
| 5437 | 5871 | ||
| 5438 | (defun org-agenda-quit () | 5872 | (defun org-agenda-quit () |
| @@ -5977,10 +6411,13 @@ the documentation of `org-diary'." | |||
| 5977 | "\\)\\>") | 6411 | "\\)\\>") |
| 5978 | org-not-done-regexp) | 6412 | org-not-done-regexp) |
| 5979 | "[^\n\r]*\\)")) | 6413 | "[^\n\r]*\\)")) |
| 6414 | (sched-re (concat ".*\n.*?" org-scheduled-time-regexp)) | ||
| 5980 | marker priority category tags | 6415 | marker priority category tags |
| 5981 | ee txt) | 6416 | ee txt) |
| 5982 | (goto-char (point-min)) | 6417 | (goto-char (point-min)) |
| 5983 | (while (re-search-forward regexp nil t) | 6418 | (while (re-search-forward regexp nil t) |
| 6419 | (when (not (and org-agenda-todo-ignore-scheduled | ||
| 6420 | (save-match-data (looking-at sched-re)))) | ||
| 5984 | (goto-char (match-beginning 1)) | 6421 | (goto-char (match-beginning 1)) |
| 5985 | (setq marker (org-agenda-new-marker (1+ (match-beginning 0))) | 6422 | (setq marker (org-agenda-new-marker (1+ (match-beginning 0))) |
| 5986 | category (org-get-category) | 6423 | category (org-get-category) |
| @@ -5997,7 +6434,9 @@ the documentation of `org-diary'." | |||
| 5997 | 'org-marker marker 'org-hd-marker marker | 6434 | 'org-marker marker 'org-hd-marker marker |
| 5998 | 'priority priority 'category category) | 6435 | 'priority priority 'category category) |
| 5999 | (push txt ee) | 6436 | (push txt ee) |
| 6000 | (goto-char (match-end 1))) | 6437 | (if org-agenda-todo-list-sublevels ; FIXME???? Change needed? |
| 6438 | (goto-char (match-end 1)) | ||
| 6439 | (org-end-of-subtree 'invisible)))) | ||
| 6001 | (nreverse ee))) | 6440 | (nreverse ee))) |
| 6002 | 6441 | ||
| 6003 | (defconst org-agenda-no-heading-message | 6442 | (defconst org-agenda-no-heading-message |
| @@ -6354,11 +6793,23 @@ only the correctly processes TXT should be returned - this is used by | |||
| 6354 | (if s1 (setq s1 (org-get-time-of-day s1 'string))) | 6793 | (if s1 (setq s1 (org-get-time-of-day s1 'string))) |
| 6355 | (if s2 (setq s2 (org-get-time-of-day s2 'string)))) | 6794 | (if s2 (setq s2 (org-get-time-of-day s2 'string)))) |
| 6356 | 6795 | ||
| 6357 | (when (and (or (eq org-agenda-remove-tags-when-in-prefix t) | 6796 | ; (when (and (or (eq org-agenda-remove-tags-when-in-prefix t) |
| 6358 | (and org-agenda-remove-tags-when-in-prefix | 6797 | ; (and org-agenda-remove-tags-when-in-prefix |
| 6359 | org-prefix-has-tag)) | 6798 | ; org-prefix-has-tag)) |
| 6360 | (string-match ":[a-zA-Z_@0-9:]+:[ \t]*$" txt)) | 6799 | ; (string-match ":[a-zA-Z_@0-9:]+:[ \t]*$" txt)) |
| 6361 | (setq txt (replace-match "" t t txt))) | 6800 | ; (setq txt (replace-match "" t t txt))) |
| 6801 | |||
| 6802 | ;; FIXME!!! | ||
| 6803 | (when (string-match "\\([ \t]+\\)\\(:[a-zA-Z_@0-9:]+:\\)[ \t]*$" txt) | ||
| 6804 | ;; Tags are in the string | ||
| 6805 | (if (or (eq org-agenda-remove-tags-when-in-prefix t) | ||
| 6806 | (and org-agenda-remove-tags-when-in-prefix | ||
| 6807 | org-prefix-has-tag)) | ||
| 6808 | (setq txt (replace-match "" t t txt)) | ||
| 6809 | (setq txt (replace-match | ||
| 6810 | (concat (make-string (max (- 50 (length txt)) 1) ?\ ) | ||
| 6811 | (match-string 2 txt)) | ||
| 6812 | t t txt)))) | ||
| 6362 | 6813 | ||
| 6363 | ;; Create the final string | 6814 | ;; Create the final string |
| 6364 | (if noprefix | 6815 | (if noprefix |
| @@ -6537,7 +6988,8 @@ and by additional input from the age of a schedules or deadline entry." | |||
| 6537 | (interactive) | 6988 | (interactive) |
| 6538 | (let* ((tags (get-text-property (point-at-bol) 'tags))) | 6989 | (let* ((tags (get-text-property (point-at-bol) 'tags))) |
| 6539 | (if tags | 6990 | (if tags |
| 6540 | (message "Tags are :%s:" (mapconcat 'identity tags ":")) | 6991 | (message "Tags are :%s:" |
| 6992 | (org-no-properties (mapconcat 'identity tags ":"))) | ||
| 6541 | (message "No tags associated with this line")))) | 6993 | (message "No tags associated with this line")))) |
| 6542 | 6994 | ||
| 6543 | (defun org-agenda-goto (&optional highlight) | 6995 | (defun org-agenda-goto (&optional highlight) |
| @@ -6723,7 +7175,7 @@ the same tree node, and the headline of the tree node in the Org-mode file." | |||
| 6723 | (beginning-of-line 1))) | 7175 | (beginning-of-line 1))) |
| 6724 | 7176 | ||
| 6725 | (defun org-get-tags-at (&optional pos) | 7177 | (defun org-get-tags-at (&optional pos) |
| 6726 | "Get a list of all headline targs applicable at POS. | 7178 | "Get a list of all headline tags applicable at POS. |
| 6727 | POS defaults to point. If tags are inherited, the list contains | 7179 | POS defaults to point. If tags are inherited, the list contains |
| 6728 | the targets in the same sequence as the headlines appear, i.e. | 7180 | the targets in the same sequence as the headlines appear, i.e. |
| 6729 | the tags of the current headline come last." | 7181 | the tags of the current headline come last." |
| @@ -6736,7 +7188,9 @@ the tags of the current headline come last." | |||
| 6736 | (condition-case nil | 7188 | (condition-case nil |
| 6737 | (while t | 7189 | (while t |
| 6738 | (if (looking-at "[^\r\n]+?:\\([a-zA-Z_@0-9:]+\\):[ \t]*\\([\n\r]\\|\\'\\)") | 7190 | (if (looking-at "[^\r\n]+?:\\([a-zA-Z_@0-9:]+\\):[ \t]*\\([\n\r]\\|\\'\\)") |
| 6739 | (setq tags (append (org-split-string (match-string 1) ":") tags))) | 7191 | (setq tags (append (org-split-string |
| 7192 | (org-match-string-no-properties 1) ":") | ||
| 7193 | tags))) | ||
| 6740 | (or org-use-tag-inheritance (error "")) | 7194 | (or org-use-tag-inheritance (error "")) |
| 6741 | (org-up-heading-all 1)) | 7195 | (org-up-heading-all 1)) |
| 6742 | (error nil)))) | 7196 | (error nil)))) |
| @@ -6808,6 +7262,40 @@ be used to request time specification in the time stamp." | |||
| 6808 | (org-time-stamp arg) | 7262 | (org-time-stamp arg) |
| 6809 | (message "Time stamp changed to %s" org-last-changed-timestamp)))) | 7263 | (message "Time stamp changed to %s" org-last-changed-timestamp)))) |
| 6810 | 7264 | ||
| 7265 | (defun org-agenda-schedule (arg) | ||
| 7266 | "Schedule the item at point." | ||
| 7267 | (interactive "P") | ||
| 7268 | (org-agenda-check-type t 'agenda 'timeline 'todo 'tags) | ||
| 7269 | (org-agenda-check-no-diary) | ||
| 7270 | (let* ((marker (or (get-text-property (point) 'org-marker) | ||
| 7271 | (org-agenda-error))) | ||
| 7272 | (buffer (marker-buffer marker)) | ||
| 7273 | (pos (marker-position marker)) | ||
| 7274 | (org-insert-labeled-timestamps-at-point nil) | ||
| 7275 | ts) | ||
| 7276 | (with-current-buffer buffer | ||
| 7277 | (widen) | ||
| 7278 | (goto-char pos) | ||
| 7279 | (setq ts (org-schedule)) | ||
| 7280 | (message "Item scheduled for %s" ts)))) | ||
| 7281 | |||
| 7282 | (defun org-agenda-deadline (arg) | ||
| 7283 | "Schedule the item at point." | ||
| 7284 | (interactive "P") | ||
| 7285 | (org-agenda-check-type t 'agenda 'timeline 'todo 'tags) | ||
| 7286 | (org-agenda-check-no-diary) | ||
| 7287 | (let* ((marker (or (get-text-property (point) 'org-marker) | ||
| 7288 | (org-agenda-error))) | ||
| 7289 | (buffer (marker-buffer marker)) | ||
| 7290 | (pos (marker-position marker)) | ||
| 7291 | (org-insert-labeled-timestamps-at-point nil) | ||
| 7292 | ts) | ||
| 7293 | (with-current-buffer buffer | ||
| 7294 | (widen) | ||
| 7295 | (goto-char pos) | ||
| 7296 | (setq ts (org-deadline)) | ||
| 7297 | (message "Deadline for this item set to %s" ts)))) | ||
| 7298 | |||
| 6811 | (defun org-get-heading () | 7299 | (defun org-get-heading () |
| 6812 | "Return the heading of the current entry, without the stars." | 7300 | "Return the heading of the current entry, without the stars." |
| 6813 | (save-excursion | 7301 | (save-excursion |
| @@ -6980,7 +7468,7 @@ are included in the output." | |||
| 6980 | 7468 | ||
| 6981 | (save-excursion | 7469 | (save-excursion |
| 6982 | (goto-char (point-min)) | 7470 | (goto-char (point-min)) |
| 6983 | (when (eq action 'sparse-tree) (hide-sublevels 1)) | 7471 | (when (eq action 'sparse-tree) (org-overview)) |
| 6984 | (while (re-search-forward re nil t) | 7472 | (while (re-search-forward re nil t) |
| 6985 | (setq todo (if (match-end 1) (match-string 2)) | 7473 | (setq todo (if (match-end 1) (match-string 2)) |
| 6986 | tags (if (match-end 4) (match-string 4))) | 7474 | tags (if (match-end 4) (match-string 4))) |
| @@ -7139,11 +7627,11 @@ The prefix arg TODO-ONLY limits the search to TODO entries." | |||
| 7139 | (defun org-set-tags (&optional arg just-align) | 7627 | (defun org-set-tags (&optional arg just-align) |
| 7140 | "Set the tags for the current headline. | 7628 | "Set the tags for the current headline. |
| 7141 | With prefix ARG, realign all tags in headings in the current buffer." | 7629 | With prefix ARG, realign all tags in headings in the current buffer." |
| 7142 | (interactive) | 7630 | (interactive "P") |
| 7143 | (let* (;(inherit (org-get-inherited-tags)) | 7631 | (let* ((re (concat "^" outline-regexp)) |
| 7144 | (re (concat "^" outline-regexp)) | ||
| 7145 | (col (current-column)) | 7632 | (col (current-column)) |
| 7146 | (current (org-get-tags)) | 7633 | (current (org-get-tags)) |
| 7634 | table current-tags inherited-tags ; computed below when needed | ||
| 7147 | tags hd empty invis) | 7635 | tags hd empty invis) |
| 7148 | (if arg | 7636 | (if arg |
| 7149 | (save-excursion | 7637 | (save-excursion |
| @@ -7153,15 +7641,22 @@ With prefix ARG, realign all tags in headings in the current buffer." | |||
| 7153 | (message "All tags realigned to column %d" org-tags-column)) | 7641 | (message "All tags realigned to column %d" org-tags-column)) |
| 7154 | (if just-align | 7642 | (if just-align |
| 7155 | (setq tags current) | 7643 | (setq tags current) |
| 7156 | (setq org-last-tags-completion-table | 7644 | (setq table (or org-tag-alist (org-get-buffer-tags)) |
| 7157 | (or (org-get-buffer-tags) | 7645 | org-last-tags-completion-table table |
| 7158 | org-last-tags-completion-table)) | 7646 | current-tags (org-split-string current ":") |
| 7159 | (setq tags | 7647 | inherited-tags (nreverse |
| 7160 | (let ((org-add-colon-after-tag-completion t)) | 7648 | (nthcdr (length current-tags) |
| 7161 | (completing-read "Tags: " 'org-tags-completion-function | 7649 | (nreverse (org-get-tags-at)))) |
| 7162 | nil nil current 'org-tags-history))) | 7650 | tags |
| 7651 | (if (or (eq t org-use-fast-tag-selection) | ||
| 7652 | (and org-use-fast-tag-selection (cdar table))) | ||
| 7653 | (org-fast-tag-selection current-tags inherited-tags table) | ||
| 7654 | (let ((org-add-colon-after-tag-completion t)) | ||
| 7655 | (completing-read "Tags: " 'org-tags-completion-function | ||
| 7656 | nil nil current 'org-tags-history)))) | ||
| 7163 | (while (string-match "[-+&]+" tags) | 7657 | (while (string-match "[-+&]+" tags) |
| 7164 | (setq tags (replace-match ":" t t tags)))) | 7658 | (setq tags (replace-match ":" t t tags)))) |
| 7659 | |||
| 7165 | ;; FIXME: still optimize this by not checking when JUST-ALIGN? | 7660 | ;; FIXME: still optimize this by not checking when JUST-ALIGN? |
| 7166 | (unless (setq empty (string-match "\\`[\t ]*\\'" tags)) | 7661 | (unless (setq empty (string-match "\\`[\t ]*\\'" tags)) |
| 7167 | (unless (string-match ":$" tags) (setq tags (concat tags ":"))) | 7662 | (unless (string-match ":$" tags) (setq tags (concat tags ":"))) |
| @@ -7212,6 +7707,79 @@ With prefix ARG, realign all tags in headings in the current buffer." | |||
| 7212 | (assoc s2 ctable))) | 7707 | (assoc s2 ctable))) |
| 7213 | )) | 7708 | )) |
| 7214 | 7709 | ||
| 7710 | (defun org-fast-tag-insert (kwd tags face &optional end) | ||
| 7711 | "Insert KDW, and the TAGS, the latter with face FACE. Also inser END." | ||
| 7712 | (insert (format "%-12s" (concat kwd ":")) | ||
| 7713 | (org-add-props (mapconcat 'identity tags " ") nil 'face face) | ||
| 7714 | (or end ""))) | ||
| 7715 | |||
| 7716 | (defun org-fast-tag-selection (current inherited table) | ||
| 7717 | "Fast tag selection with single keys. | ||
| 7718 | CURRENT is the current list of tags in the headline, INHERITED is the | ||
| 7719 | list of inherited tags, and TABLE is an alist of tags and corresponding keys. | ||
| 7720 | If the keys are nil, a-z are automatically assigned. | ||
| 7721 | Returns the new tags string, or nil to not change the current settings." | ||
| 7722 | (let* ((maxlen (apply 'max (mapcar (lambda (x) | ||
| 7723 | (string-width (car x))) table))) | ||
| 7724 | (fwidth (+ maxlen 3 1 3)) | ||
| 7725 | (ncol (/ (window-width) fwidth)) | ||
| 7726 | (i-face 'org-done) | ||
| 7727 | (c-face 'org-tag) | ||
| 7728 | tg cnt e c char ntable tbl rtn) | ||
| 7729 | (save-window-excursion | ||
| 7730 | (delete-other-windows) | ||
| 7731 | (split-window-vertically) | ||
| 7732 | (switch-to-buffer-other-window (get-buffer-create " *Org tags*")) | ||
| 7733 | (erase-buffer) | ||
| 7734 | (org-fast-tag-insert "Inherited" inherited i-face "\n") | ||
| 7735 | (org-fast-tag-insert "Current" current c-face "\n\n") | ||
| 7736 | (setq tbl table char (1- ?a) cnt 0) | ||
| 7737 | (while (setq e (pop tbl)) | ||
| 7738 | (setq tg (car e) c (or (cdr e) (setq char (1+ char)))) | ||
| 7739 | (setq tg (org-add-props tg nil 'face | ||
| 7740 | (cond | ||
| 7741 | ((member tg current) c-face) | ||
| 7742 | ((member tg inherited) i-face) | ||
| 7743 | (t nil)))) | ||
| 7744 | (insert "[" c "] " tg (make-string | ||
| 7745 | (- fwidth 4 (length tg)) ?\ )) | ||
| 7746 | (push (cons tg c) ntable) | ||
| 7747 | (when (= (setq cnt (1+ cnt)) ncol) | ||
| 7748 | (insert "\n") | ||
| 7749 | (setq cnt 0))) | ||
| 7750 | (insert "\n") | ||
| 7751 | (goto-char (point-min)) | ||
| 7752 | (if (fboundp 'fit-window-to-buffer) (fit-window-to-buffer)) | ||
| 7753 | (setq rtn | ||
| 7754 | (catch 'exit | ||
| 7755 | (while t | ||
| 7756 | (message "[key]:Toggle SPC: clear current RET accept") | ||
| 7757 | (setq c (read-char-exclusive)) | ||
| 7758 | (cond | ||
| 7759 | ((= c ?\r) (throw 'exit t)) | ||
| 7760 | ((= c ?\C-g) (throw 'exit nil)) | ||
| 7761 | ((= c ?\ ) (setq current nil)) | ||
| 7762 | (t (setq e (rassoc c ntable) tg (car e)) | ||
| 7763 | (if (member tg current) | ||
| 7764 | (setq current (delete tg current)) | ||
| 7765 | (setq current (append current (list tg)))))) | ||
| 7766 | (goto-char (point-min)) | ||
| 7767 | (beginning-of-line 2) | ||
| 7768 | (delete-region (point) (point-at-eol)) | ||
| 7769 | (org-fast-tag-insert "Current" current c-face) | ||
| 7770 | (while (re-search-forward "\\[.\\] \\([a-zA-Z0-9_@]+\\)" nil t) | ||
| 7771 | (setq tg (match-string 1)) | ||
| 7772 | (add-text-properties (match-beginning 1) (match-end 1) | ||
| 7773 | (list 'face | ||
| 7774 | (cond | ||
| 7775 | ((member tg current) c-face) | ||
| 7776 | ((member tg inherited) i-face) | ||
| 7777 | (t nil))))) | ||
| 7778 | (goto-char (point-min))))) | ||
| 7779 | (if rtn | ||
| 7780 | (mapconcat 'identity current ":") | ||
| 7781 | nil)))) | ||
| 7782 | |||
| 7215 | (defun org-get-tags () | 7783 | (defun org-get-tags () |
| 7216 | "Get the TAGS string in the current headline." | 7784 | "Get the TAGS string in the current headline." |
| 7217 | (unless (org-on-heading-p) | 7785 | (unless (org-on-heading-p) |
| @@ -7234,6 +7802,50 @@ With prefix ARG, realign all tags in headings in the current buffer." | |||
| 7234 | 7802 | ||
| 7235 | ;;; Link Stuff | 7803 | ;;; Link Stuff |
| 7236 | 7804 | ||
| 7805 | (defvar org-create-file-search-functions nil | ||
| 7806 | "List of functions to construct the right search string for a file link. | ||
| 7807 | These functions are called in turn with point at the location to | ||
| 7808 | which the link should point. | ||
| 7809 | |||
| 7810 | A function in the hook should first test if it would like to | ||
| 7811 | handle this file type, for example by checking the major-mode or | ||
| 7812 | the file extension. If it decides not to handle this file, it | ||
| 7813 | should just return nil to give other functions a chance. If it | ||
| 7814 | does handle the file, it must return the search string to be used | ||
| 7815 | when following the link. The search string will be part of the | ||
| 7816 | file link, given after a double colon, and `org-open-at-point' | ||
| 7817 | will automatically search for it. If special measures must be | ||
| 7818 | taken to make the search successful, another function should be | ||
| 7819 | added to the companion hook `org-execute-file-search-functions', | ||
| 7820 | which see. | ||
| 7821 | |||
| 7822 | A function in this hook may also use `setq' to set the variable | ||
| 7823 | `description' to provide a suggestion for the descriptive text to | ||
| 7824 | be used for this link when it gets inserted into an Org-mode | ||
| 7825 | buffer with \\[org-insert-link].") | ||
| 7826 | |||
| 7827 | (defvar org-execute-file-search-functions nil | ||
| 7828 | "List of functions to execute a file search triggered by a link. | ||
| 7829 | |||
| 7830 | Functions added to this hook must accept a single argument, the | ||
| 7831 | search string that was part of the file link, the part after the | ||
| 7832 | double colon. The function must first check if it would like to | ||
| 7833 | handle this search, for example by checking the major-mode or the | ||
| 7834 | file extension. If it decides not to handle this search, it | ||
| 7835 | should just return nil to give other functions a chance. If it | ||
| 7836 | does handle the search, it must return a non-nil value to keep | ||
| 7837 | other functions from trying. | ||
| 7838 | |||
| 7839 | Each function can access the current prefix argument through the | ||
| 7840 | variable `current-prefix-argument'. Note that a single prefix is | ||
| 7841 | used to force opening a link in Emacs, so it may be good to only | ||
| 7842 | use a numeric or double prefix to guide the search function. | ||
| 7843 | |||
| 7844 | In case this is needed, a function in this hook can also restore | ||
| 7845 | the window configuration before `org-open-at-point' was called using: | ||
| 7846 | |||
| 7847 | (set-window-configuration org-window-config-before-follow-link)") | ||
| 7848 | |||
| 7237 | (defun org-find-file-at-mouse (ev) | 7849 | (defun org-find-file-at-mouse (ev) |
| 7238 | "Open file link or URL at mouse." | 7850 | "Open file link or URL at mouse." |
| 7239 | (interactive "e") | 7851 | (interactive "e") |
| @@ -7246,6 +7858,10 @@ With prefix ARG, realign all tags in headings in the current buffer." | |||
| 7246 | (mouse-set-point ev) | 7858 | (mouse-set-point ev) |
| 7247 | (org-open-at-point)) | 7859 | (org-open-at-point)) |
| 7248 | 7860 | ||
| 7861 | (defvar org-window-config-before-follow-link nil | ||
| 7862 | "The window configuration before following a link. | ||
| 7863 | This is saved in case the need arises to restore it.") | ||
| 7864 | |||
| 7249 | (defun org-open-at-point (&optional in-emacs) | 7865 | (defun org-open-at-point (&optional in-emacs) |
| 7250 | "Open link at or after point. | 7866 | "Open link at or after point. |
| 7251 | If there is no link at point, this function will search forward up to | 7867 | If there is no link at point, this function will search forward up to |
| @@ -7253,6 +7869,7 @@ the end of the current subtree. | |||
| 7253 | Normally, files will be opened by an appropriate application. If the | 7869 | Normally, files will be opened by an appropriate application. If the |
| 7254 | optional argument IN-EMACS is non-nil, Emacs will visit the file." | 7870 | optional argument IN-EMACS is non-nil, Emacs will visit the file." |
| 7255 | (interactive "P") | 7871 | (interactive "P") |
| 7872 | (setq org-window-config-before-follow-link (current-window-configuration)) | ||
| 7256 | (org-remove-occur-highlights nil nil t) | 7873 | (org-remove-occur-highlights nil nil t) |
| 7257 | (if (org-at-timestamp-p) | 7874 | (if (org-at-timestamp-p) |
| 7258 | (org-agenda-list nil (time-to-days (org-time-string-to-time | 7875 | (org-agenda-list nil (time-to-days (org-time-string-to-time |
| @@ -7337,6 +7954,7 @@ optional argument IN-EMACS is non-nil, Emacs will visit the file." | |||
| 7337 | 7954 | ||
| 7338 | ((string= type "file") | 7955 | ((string= type "file") |
| 7339 | (if (string-match "::?\\([0-9]+\\)\\'" path) ;; second : optional | 7956 | (if (string-match "::?\\([0-9]+\\)\\'" path) ;; second : optional |
| 7957 | ;; FIXME: It is unsafe to allow a single colon. | ||
| 7340 | (setq line (string-to-number (match-string 1 path)) | 7958 | (setq line (string-to-number (match-string 1 path)) |
| 7341 | path (substring path 0 (match-beginning 0))) | 7959 | path (substring path 0 (match-beginning 0))) |
| 7342 | (if (string-match "::\\(.+\\)\\'" path) | 7960 | (if (string-match "::\\(.+\\)\\'" path) |
| @@ -7350,6 +7968,9 @@ optional argument IN-EMACS is non-nil, Emacs will visit the file." | |||
| 7350 | ((string= type "bbdb") | 7968 | ((string= type "bbdb") |
| 7351 | (org-follow-bbdb-link path)) | 7969 | (org-follow-bbdb-link path)) |
| 7352 | 7970 | ||
| 7971 | ((string= type "info") | ||
| 7972 | (org-follow-info-link path)) | ||
| 7973 | |||
| 7353 | ((string= type "gnus") | 7974 | ((string= type "gnus") |
| 7354 | (let (group article) | 7975 | (let (group article) |
| 7355 | (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path)) | 7976 | (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path)) |
| @@ -7397,8 +8018,8 @@ optional argument IN-EMACS is non-nil, Emacs will visit the file." | |||
| 7397 | (setq cmd (replace-match "<" t t cmd))) | 8018 | (setq cmd (replace-match "<" t t cmd))) |
| 7398 | (while (string-match "@}" cmd) | 8019 | (while (string-match "@}" cmd) |
| 7399 | (setq cmd (replace-match ">" t t cmd))) | 8020 | (setq cmd (replace-match ">" t t cmd))) |
| 7400 | (if (or (not org-confirm-shell-links) | 8021 | (if (or (not org-confirm-shell-link-function) |
| 7401 | (funcall org-confirm-shell-links | 8022 | (funcall org-confirm-shell-link-function |
| 7402 | (format "Execute \"%s\" in shell? " | 8023 | (format "Execute \"%s\" in shell? " |
| 7403 | (org-add-props cmd nil | 8024 | (org-add-props cmd nil |
| 7404 | 'face 'org-warning)))) | 8025 | 'face 'org-warning)))) |
| @@ -7407,6 +8028,16 @@ optional argument IN-EMACS is non-nil, Emacs will visit the file." | |||
| 7407 | (shell-command cmd)) | 8028 | (shell-command cmd)) |
| 7408 | (error "Abort")))) | 8029 | (error "Abort")))) |
| 7409 | 8030 | ||
| 8031 | ((string= type "elisp") | ||
| 8032 | (let ((cmd path)) | ||
| 8033 | (if (or (not org-confirm-elisp-link-function) | ||
| 8034 | (funcall org-confirm-elisp-link-function | ||
| 8035 | (format "Execute \"%s\" as elisp? " | ||
| 8036 | (org-add-props cmd nil | ||
| 8037 | 'face 'org-warning)))) | ||
| 8038 | (message "%s => %s" cmd (eval (read cmd))) | ||
| 8039 | (error "Abort")))) | ||
| 8040 | |||
| 7410 | (t | 8041 | (t |
| 7411 | (browse-url-at-point)))))) | 8042 | (browse-url-at-point)))))) |
| 7412 | 8043 | ||
| @@ -7423,73 +8054,77 @@ in all files." | |||
| 7423 | (pos (point)) | 8054 | (pos (point)) |
| 7424 | (pre "") (post "") | 8055 | (pre "") (post "") |
| 7425 | words re0 re1 re2 re3 re4 re5 re2a reall camel) | 8056 | words re0 re1 re2 re3 re4 re5 re2a reall camel) |
| 7426 | (cond ((save-excursion | 8057 | (cond |
| 7427 | (goto-char (point-min)) | 8058 | ;; First check if there are any special |
| 7428 | (and | 8059 | ((run-hook-with-args-until-success 'org-execute-file-search-functions s)) |
| 7429 | (re-search-forward | 8060 | ;; Now try the builtin stuff |
| 7430 | (concat "<<" (regexp-quote s0) ">>") nil t) | 8061 | ((save-excursion |
| 7431 | (setq pos (match-beginning 0)))) | 8062 | (goto-char (point-min)) |
| 7432 | ;; There is an exact target for this | 8063 | (and |
| 7433 | (goto-char pos)) | 8064 | (re-search-forward |
| 7434 | ((string-match "^/\\(.*\\)/$" s) | 8065 | (concat "<<" (regexp-quote s0) ">>") nil t) |
| 7435 | ;; A regular expression | 8066 | (setq pos (match-beginning 0)))) |
| 7436 | (cond | 8067 | ;; There is an exact target for this |
| 7437 | ((eq major-mode 'org-mode) | 8068 | (goto-char pos)) |
| 7438 | (org-occur (match-string 1 s))) | 8069 | ((string-match "^/\\(.*\\)/$" s) |
| 7439 | ;;((eq major-mode 'dired-mode) | 8070 | ;; A regular expression |
| 7440 | ;; (grep (concat "grep -n -e '" (match-string 1 s) "' *"))) | 8071 | (cond |
| 7441 | (t (org-do-occur (match-string 1 s))))) | 8072 | ((eq major-mode 'org-mode) |
| 7442 | ((or (setq camel (string-match (concat "^" org-camel-regexp "$") s)) | 8073 | (org-occur (match-string 1 s))) |
| 7443 | t) | 8074 | ;;((eq major-mode 'dired-mode) |
| 7444 | ;; A camel or a normal search string | 8075 | ;; (grep (concat "grep -n -e '" (match-string 1 s) "' *"))) |
| 7445 | (when (equal (string-to-char s) ?*) | 8076 | (t (org-do-occur (match-string 1 s))))) |
| 7446 | ;; Anchor on headlines, post may include tags. | 8077 | ((or (setq camel (string-match (concat "^" org-camel-regexp "$") s)) |
| 7447 | (setq pre "^\\*+[ \t]*\\(\\sw+\\)?[ \t]*" | 8078 | t) |
| 7448 | post "[ \t]*\\([ \t]+:[a-zA-Z_@0-9:+]:[ \t]*\\)?$" | 8079 | ;; A camel or a normal search string |
| 7449 | s (substring s 1))) | 8080 | (when (equal (string-to-char s) ?*) |
| 7450 | (remove-text-properties | 8081 | ;; Anchor on headlines, post may include tags. |
| 7451 | 0 (length s) | 8082 | (setq pre "^\\*+[ \t]*\\(?:\\sw+\\)?[ \t]*" |
| 7452 | '(face nil mouse-face nil keymap nil fontified nil) s) | 8083 | post "[ \t]*\\(?:[ \t]+:[a-zA-Z_@0-9:+]:[ \t]*\\)?$" |
| 7453 | ;; Make a series of regular expressions to find a match | 8084 | s (substring s 1))) |
| 7454 | (setq words | 8085 | (remove-text-properties |
| 7455 | (if camel | 8086 | 0 (length s) |
| 7456 | (org-camel-to-words s) | 8087 | '(face nil mouse-face nil keymap nil fontified nil) s) |
| 7457 | (org-split-string s "[ \n\r\t]+")) | 8088 | ;; Make a series of regular expressions to find a match |
| 7458 | re0 (concat "<<" (regexp-quote s0) ">>") | 8089 | (setq words |
| 7459 | re2 (concat "\\<" (mapconcat 'downcase words "[ \t]+") "\\>") | 8090 | (if camel |
| 7460 | re2a (concat "\\<" (mapconcat 'downcase words "[ \t\r\n]+") "\\>") | 8091 | (org-camel-to-words s) |
| 7461 | re4 (concat "\\<" (mapconcat 'downcase words "[^a-zA-Z_\r\n]+") "\\>") | 8092 | (org-split-string s "[ \n\r\t]+")) |
| 7462 | re1 (concat pre re2 post) | 8093 | re0 (concat "\\(<<" (regexp-quote s0) ">>\\)") |
| 7463 | re3 (concat pre re4 post) | 8094 | re2 (concat "[ \t\r\n]\\(" (mapconcat 'downcase words "[ \t]+") "\\)[ \t\r\n]") |
| 7464 | re5 (concat pre ".*" re4) | 8095 | re2a (concat "[ \t\r\n]\\(" (mapconcat 'downcase words "[ \t\r\n]+") "\\)[ \t\r\n]") |
| 7465 | re2 (concat pre re2) | 8096 | re4 (concat "[^a-zA-Z_]\\(" (mapconcat 'downcase words "[^a-zA-Z_\r\n]+") "\\)[^a-zA-Z_]") |
| 7466 | re2a (concat pre re2a) | 8097 | re1 (concat pre re2 post) |
| 7467 | re4 (concat pre re4) | 8098 | re3 (concat pre re4 post) |
| 7468 | reall (concat "\\(" re0 "\\)\\|\\(" re1 "\\)\\|\\(" re2 | 8099 | re5 (concat pre ".*" re4) |
| 7469 | "\\)\\|\\(" re3 "\\)\\|\\(" re4 "\\)\\|\\(" | 8100 | re2 (concat pre re2) |
| 7470 | re5 "\\)" | 8101 | re2a (concat pre re2a) |
| 7471 | )) | 8102 | re4 (concat pre re4) |
| 7472 | (cond | 8103 | reall (concat "\\(" re0 "\\)\\|\\(" re1 "\\)\\|\\(" re2 |
| 7473 | ((eq type 'org-occur) (org-occur reall)) | 8104 | "\\)\\|\\(" re3 "\\)\\|\\(" re4 "\\)\\|\\(" |
| 7474 | ((eq type 'occur) (org-do-occur (downcase reall) 'cleanup)) | 8105 | re5 "\\)" |
| 7475 | (t (goto-char (point-min)) | 8106 | )) |
| 7476 | (if (or (org-search-not-link re0 nil t) | 8107 | (cond |
| 7477 | (org-search-not-link re1 nil t) | 8108 | ((eq type 'org-occur) (org-occur reall)) |
| 7478 | (org-search-not-link re2 nil t) | 8109 | ((eq type 'occur) (org-do-occur (downcase reall) 'cleanup)) |
| 7479 | (org-search-not-link re2a nil t) | 8110 | (t (goto-char (point-min)) |
| 7480 | (org-search-not-link re3 nil t) | 8111 | (if (or (org-search-not-link re0 nil t) |
| 7481 | (org-search-not-link re4 nil t) | 8112 | (org-search-not-link re1 nil t) |
| 7482 | (org-search-not-link re5 nil t) | 8113 | (org-search-not-link re2 nil t) |
| 7483 | ) | 8114 | (org-search-not-link re2a nil t) |
| 7484 | (goto-char (match-beginning 0)) | 8115 | (org-search-not-link re3 nil t) |
| 7485 | (goto-char pos) | 8116 | (org-search-not-link re4 nil t) |
| 7486 | (error "No match"))))) | 8117 | (org-search-not-link re5 nil t) |
| 7487 | (t | 8118 | ) |
| 7488 | ;; Normal string-search | 8119 | (goto-char (match-beginning 1)) ;; Fixme: does every re have group 1? |
| 7489 | (goto-char (point-min)) | 8120 | (goto-char pos) |
| 7490 | (if (search-forward s nil t) | 8121 | (error "No match"))))) |
| 7491 | (goto-char (match-beginning 0)) | 8122 | (t |
| 7492 | (error "No match")))) | 8123 | ;; Normal string-search |
| 8124 | (goto-char (point-min)) | ||
| 8125 | (if (search-forward s nil t) | ||
| 8126 | (goto-char (match-beginning 0)) | ||
| 8127 | (error "No match")))) | ||
| 7493 | (and (eq major-mode 'org-mode) (org-show-hierarchy-above)))) | 8128 | (and (eq major-mode 'org-mode) (org-show-hierarchy-above)))) |
| 7494 | 8129 | ||
| 7495 | (defun org-search-not-link (&rest args) | 8130 | (defun org-search-not-link (&rest args) |
| @@ -7609,6 +8244,18 @@ onto the ring." | |||
| 7609 | (delete-window (get-buffer-window "*BBDB*")) | 8244 | (delete-window (get-buffer-window "*BBDB*")) |
| 7610 | (error "No matching BBDB record"))))) | 8245 | (error "No matching BBDB record"))))) |
| 7611 | 8246 | ||
| 8247 | |||
| 8248 | (defun org-follow-info-link (name) | ||
| 8249 | "Follow an info file & node link to NAME." | ||
| 8250 | (if (or (string-match "\\(.*\\)::?\\(.*\\)" name) | ||
| 8251 | (string-match "\\(.*\\)" name)) | ||
| 8252 | (progn | ||
| 8253 | (require 'info) | ||
| 8254 | (if (match-string 2 name) ; If there isn't a node, choose "Top" | ||
| 8255 | (Info-find-node (match-string 1 name) (match-string 2 name)) | ||
| 8256 | (Info-find-node (match-string 1 name) "Top"))) | ||
| 8257 | (message (concat "Could not open: " name)))) | ||
| 8258 | |||
| 7612 | (defun org-follow-gnus-link (&optional group article) | 8259 | (defun org-follow-gnus-link (&optional group article) |
| 7613 | "Follow a Gnus link to GROUP and ARTICLE." | 8260 | "Follow a Gnus link to GROUP and ARTICLE." |
| 7614 | (require 'gnus) | 8261 | (require 'gnus) |
| @@ -7792,6 +8439,61 @@ folders." | |||
| 7792 | (kill-this-buffer) | 8439 | (kill-this-buffer) |
| 7793 | (error "Message not found")))) | 8440 | (error "Message not found")))) |
| 7794 | 8441 | ||
| 8442 | ;; BibTeX links | ||
| 8443 | |||
| 8444 | ;; Use the custom search meachnism to construct and use search strings for | ||
| 8445 | ;; file links to BibTeX database entries. | ||
| 8446 | |||
| 8447 | (defun org-create-file-search-in-bibtex () | ||
| 8448 | "Create the search string and description for a BibTeX database entry." | ||
| 8449 | (when (eq major-mode 'bibtex-mode) | ||
| 8450 | ;; yes, we want to construct this search string. | ||
| 8451 | ;; Make a good description for this entry, using names, year and the title | ||
| 8452 | ;; Put it into the `description' variable which is dynamically scoped. | ||
| 8453 | (let ((bibtex-autokey-names 1) | ||
| 8454 | (bibtex-autokey-names-stretch 1) | ||
| 8455 | (bibtex-autokey-name-case-convert-function 'identity) | ||
| 8456 | (bibtex-autokey-name-separator " & ") | ||
| 8457 | (bibtex-autokey-additional-names " et al.") | ||
| 8458 | (bibtex-autokey-year-length 4) | ||
| 8459 | (bibtex-autokey-name-year-separator " ") | ||
| 8460 | (bibtex-autokey-titlewords 3) | ||
| 8461 | (bibtex-autokey-titleword-separator " ") | ||
| 8462 | (bibtex-autokey-titleword-case-convert-function 'identity) | ||
| 8463 | (bibtex-autokey-titleword-length 'infty) | ||
| 8464 | (bibtex-autokey-year-title-separator ": ")) | ||
| 8465 | (setq description (bibtex-generate-autokey))) | ||
| 8466 | ;; Now parse the entry, get the key and return it. | ||
| 8467 | (save-excursion | ||
| 8468 | (bibtex-beginning-of-entry) | ||
| 8469 | (cdr (assoc "=key=" (bibtex-parse-entry)))))) | ||
| 8470 | |||
| 8471 | (defun org-execute-file-search-in-bibtex (s) | ||
| 8472 | "Find the link search string S as a key for a database entry." | ||
| 8473 | (when (eq major-mode 'bibtex-mode) | ||
| 8474 | ;; Yes, we want to do the search in this file. | ||
| 8475 | ;; We construct a regexp that searches for "@entrytype{" followed by the key | ||
| 8476 | (goto-char (point-min)) | ||
| 8477 | (and (re-search-forward (concat "@[a-zA-Z]+[ \t\n]*{[ \t\n]*" | ||
| 8478 | (regexp-quote s) "[ \t\n]*,") nil t) | ||
| 8479 | (goto-char (match-beginning 0))) | ||
| 8480 | (if (and (match-beginning 0) (equal current-prefix-arg '(16))) | ||
| 8481 | ;; Use double prefix to indicate that any web link should be browsed | ||
| 8482 | (let ((b (current-buffer)) (p (point))) | ||
| 8483 | ;; Restore the window configuration because we just use the web link | ||
| 8484 | (set-window-configuration org-window-config-before-follow-link) | ||
| 8485 | (save-excursion (set-buffer b) (goto-char p) | ||
| 8486 | (bibtex-url))) | ||
| 8487 | (recenter 0)) ; Move entry start to beginning of window | ||
| 8488 | ;; return t to indicate that the search is done. | ||
| 8489 | t)) | ||
| 8490 | |||
| 8491 | ;; Finally add the functions to the right hooks. | ||
| 8492 | (add-hook 'org-create-file-search-functions 'org-create-file-search-in-bibtex) | ||
| 8493 | (add-hook 'org-execute-file-search-functions 'org-execute-file-search-in-bibtex) | ||
| 8494 | |||
| 8495 | ;; end of Bibtex link setup | ||
| 8496 | |||
| 7795 | (defun org-upgrade-old-links (&optional query-description) | 8497 | (defun org-upgrade-old-links (&optional query-description) |
| 7796 | "Transfer old <...> style links to new [[...]] style links. | 8498 | "Transfer old <...> style links to new [[...]] style links. |
| 7797 | With arg query-description, ask at each match for a description text to use | 8499 | With arg query-description, ask at each match for a description text to use |
| @@ -7907,7 +8609,7 @@ For some link types, a prefix arg is interpreted: | |||
| 7907 | For links to usenet articles, arg negates `org-usenet-links-prefer-google'. | 8609 | For links to usenet articles, arg negates `org-usenet-links-prefer-google'. |
| 7908 | For file links, arg negates `org-context-in-file-links'." | 8610 | For file links, arg negates `org-context-in-file-links'." |
| 7909 | (interactive "P") | 8611 | (interactive "P") |
| 7910 | (let (link cpltxt desc txt (pos (point))) | 8612 | (let (link cpltxt desc description search txt (pos (point))) |
| 7911 | (cond | 8613 | (cond |
| 7912 | 8614 | ||
| 7913 | ((eq major-mode 'bbdb-mode) | 8615 | ((eq major-mode 'bbdb-mode) |
| @@ -7917,6 +8619,13 @@ For file links, arg negates `org-context-in-file-links'." | |||
| 7917 | (bbdb-record-company (bbdb-current-record)))) | 8619 | (bbdb-record-company (bbdb-current-record)))) |
| 7918 | link (org-make-link cpltxt))) | 8620 | link (org-make-link cpltxt))) |
| 7919 | 8621 | ||
| 8622 | ((eq major-mode 'Info-mode) | ||
| 8623 | (setq link (org-make-link "info:" | ||
| 8624 | (file-name-nondirectory Info-current-file) | ||
| 8625 | ":" Info-current-node)) | ||
| 8626 | (setq cpltxt (concat (file-name-nondirectory Info-current-file) | ||
| 8627 | ":" Info-current-node))) | ||
| 8628 | |||
| 7920 | ((eq major-mode 'calendar-mode) | 8629 | ((eq major-mode 'calendar-mode) |
| 7921 | (let ((cd (calendar-cursor-to-date))) | 8630 | (let ((cd (calendar-cursor-to-date))) |
| 7922 | (setq link | 8631 | (setq link |
| @@ -8020,6 +8729,12 @@ For file links, arg negates `org-context-in-file-links'." | |||
| 8020 | (setq cpltxt w3m-current-url | 8729 | (setq cpltxt w3m-current-url |
| 8021 | link (org-make-link cpltxt))) | 8730 | link (org-make-link cpltxt))) |
| 8022 | 8731 | ||
| 8732 | ((setq search (run-hook-with-args-until-success | ||
| 8733 | 'org-create-file-search-functions)) | ||
| 8734 | (setq link (concat "file:" (abbreviate-file-name buffer-file-name) | ||
| 8735 | "::" search)) | ||
| 8736 | (setq cpltxt (or description link))) ;; FIXME: is this the best way? | ||
| 8737 | |||
| 8023 | ((eq major-mode 'org-mode) | 8738 | ((eq major-mode 'org-mode) |
| 8024 | ;; Just link to current headline | 8739 | ;; Just link to current headline |
| 8025 | (setq cpltxt (concat "file:" | 8740 | (setq cpltxt (concat "file:" |
| @@ -8039,12 +8754,13 @@ For file links, arg negates `org-context-in-file-links'." | |||
| 8039 | ((org-region-active-p) | 8754 | ((org-region-active-p) |
| 8040 | (buffer-substring (region-beginning) (region-end))) | 8755 | (buffer-substring (region-beginning) (region-end))) |
| 8041 | (t (buffer-substring (point-at-bol) (point-at-eol))))) | 8756 | (t (buffer-substring (point-at-bol) (point-at-eol))))) |
| 8042 | (setq cpltxt | 8757 | (when (string-match "\\S-" txt) |
| 8043 | (concat cpltxt "::" | 8758 | (setq cpltxt |
| 8044 | (if org-file-link-context-use-camel-case | 8759 | (concat cpltxt "::" |
| 8045 | (org-make-org-heading-camel txt) | 8760 | (if org-file-link-context-use-camel-case |
| 8046 | (org-make-org-heading-search-string txt))) | 8761 | (org-make-org-heading-camel txt) |
| 8047 | desc "NONE"))) | 8762 | (org-make-org-heading-search-string txt))) |
| 8763 | desc "NONE")))) | ||
| 8048 | (if (string-match "::\\'" cpltxt) | 8764 | (if (string-match "::\\'" cpltxt) |
| 8049 | (setq cpltxt (substring cpltxt 0 -2))) | 8765 | (setq cpltxt (substring cpltxt 0 -2))) |
| 8050 | (setq link (org-make-link cpltxt))) | 8766 | (setq link (org-make-link cpltxt))) |
| @@ -8058,12 +8774,14 @@ For file links, arg negates `org-context-in-file-links'." | |||
| 8058 | (setq txt (if (org-region-active-p) | 8774 | (setq txt (if (org-region-active-p) |
| 8059 | (buffer-substring (region-beginning) (region-end)) | 8775 | (buffer-substring (region-beginning) (region-end)) |
| 8060 | (buffer-substring (point-at-bol) (point-at-eol)))) | 8776 | (buffer-substring (point-at-bol) (point-at-eol)))) |
| 8061 | (setq cpltxt | 8777 | ;; Only use search option if there is some text. |
| 8062 | (concat cpltxt "::" | 8778 | (when (string-match "\\S-" txt) |
| 8063 | (if org-file-link-context-use-camel-case | 8779 | (setq cpltxt |
| 8064 | (org-make-org-heading-camel txt) | 8780 | (concat cpltxt "::" |
| 8065 | (org-make-org-heading-search-string txt))) | 8781 | (if org-file-link-context-use-camel-case |
| 8066 | desc "NONE")) | 8782 | (org-make-org-heading-camel txt) |
| 8783 | (org-make-org-heading-search-string txt))) | ||
| 8784 | desc "NONE"))) | ||
| 8067 | (setq link (org-make-link cpltxt))) | 8785 | (setq link (org-make-link cpltxt))) |
| 8068 | 8786 | ||
| 8069 | ((interactive-p) | 8787 | ((interactive-p) |
| @@ -8287,16 +9005,39 @@ is in the current directory or below." | |||
| 8287 | ;; URL-like link, normalize the use of angular brackets. | 9005 | ;; URL-like link, normalize the use of angular brackets. |
| 8288 | (setq link (org-make-link (org-remove-angle-brackets link)))) | 9006 | (setq link (org-make-link (org-remove-angle-brackets link)))) |
| 8289 | 9007 | ||
| 8290 | ;; Check if we are linking to the current file. If yes, simplify the link. | 9008 | ;; Check if we are linking to the current file with a search option |
| 9009 | ;; If yes, simplify the link by using only the search option. | ||
| 8291 | (when (string-match "\\<file:\\(.+?\\)::\\([^>]+\\)" link) | 9010 | (when (string-match "\\<file:\\(.+?\\)::\\([^>]+\\)" link) |
| 8292 | (let* ((path (match-string 1 link)) | 9011 | (let* ((path (match-string 1 link)) |
| 8293 | (case-fold-search nil) | 9012 | (case-fold-search nil) |
| 8294 | (search (match-string 2 link))) | 9013 | (search (match-string 2 link))) |
| 8295 | (when (save-match-data | 9014 | (save-match-data |
| 8296 | (equal (file-truename buffer-file-name) | 9015 | (if (equal (file-truename buffer-file-name) (file-truename path)) |
| 8297 | (file-truename path))) | 9016 | ;; We are linking to this same file, with a search option |
| 8298 | ;; We are linking to this same file, with a search option | 9017 | (setq link search))))) |
| 8299 | (setq link search)))) | 9018 | |
| 9019 | ;; Check if we can/should use a relative path. If yes, simplify the link | ||
| 9020 | (when (string-match "\\<file:\\(.*\\)" link) | ||
| 9021 | (let* ((path (match-string 1 link)) | ||
| 9022 | (case-fold-search nil)) | ||
| 9023 | (cond | ||
| 9024 | ((eq org-link-file-path-type 'absolute) | ||
| 9025 | (setq path (abbreviate-file-name (expand-file-name path)))) | ||
| 9026 | ((eq org-link-file-path-type 'noabbrev) | ||
| 9027 | (setq path (expand-file-name path))) | ||
| 9028 | ((eq org-link-file-path-type 'relative) | ||
| 9029 | (setq path (file-relative-name path))) | ||
| 9030 | (t | ||
| 9031 | (save-match-data | ||
| 9032 | (if (string-match (concat "^" (regexp-quote | ||
| 9033 | (file-name-as-directory | ||
| 9034 | (expand-file-name ".")))) | ||
| 9035 | (expand-file-name path)) | ||
| 9036 | ;; We are linking a file with relative path name. | ||
| 9037 | (setq path (substring (expand-file-name path) | ||
| 9038 | (match-end 0))))))) | ||
| 9039 | (setq link (concat "file:" path)))) | ||
| 9040 | |||
| 8300 | (setq desc (read-string "Description: " desc)) | 9041 | (setq desc (read-string "Description: " desc)) |
| 8301 | (unless (string-match "\\S-" desc) (setq desc nil)) | 9042 | (unless (string-match "\\S-" desc) (setq desc nil)) |
| 8302 | (if remove (apply 'delete-region remove)) | 9043 | (if remove (apply 'delete-region remove)) |
| @@ -8329,48 +9070,52 @@ RET on headline -> Store as sublevel entry to current headline | |||
| 8329 | 9070 | ||
| 8330 | ;;;###autoload | 9071 | ;;;###autoload |
| 8331 | (defun org-remember-apply-template () | 9072 | (defun org-remember-apply-template () |
| 8332 | "Initialize *remember* buffer with template, invode `org-mode'. | 9073 | "Initialize *remember* buffer with template, invoke `org-mode'. |
| 8333 | This function should be placed into `remember-mode-hook' and in fact requires | 9074 | This function should be placed into `remember-mode-hook' and in fact requires |
| 8334 | to be run from that hook to fucntion properly." | 9075 | to be run from that hook to fucntion properly." |
| 8335 | (when org-remember-templates | 9076 | (if org-remember-templates |
| 8336 | (let* ((entry (if (= (length org-remember-templates) 1) | 9077 | |
| 8337 | (cdar org-remember-templates) | 9078 | (let* ((entry (if (= (length org-remember-templates) 1) |
| 8338 | (message "Select template: %s" | 9079 | (cdar org-remember-templates) |
| 8339 | (mapconcat | 9080 | (message "Select template: %s" |
| 8340 | (lambda (x) (char-to-string (car x))) | 9081 | (mapconcat |
| 8341 | org-remember-templates " ")) | 9082 | (lambda (x) (char-to-string (car x))) |
| 8342 | (cdr (assoc (read-char-exclusive) org-remember-templates)))) | 9083 | org-remember-templates " ")) |
| 8343 | (tpl (if (consp (cdr entry)) (cadr entry) (cdr entry))) | 9084 | (cdr (assoc (read-char-exclusive) org-remember-templates)))) |
| 8344 | (file (if (consp (cdr entry)) (nth 2 entry))) | 9085 | (tpl (car entry)) |
| 8345 | (v-t (format-time-string (car org-time-stamp-formats) (org-current-time))) | 9086 | (file (if (consp (cdr entry)) (nth 1 entry))) |
| 8346 | (v-T (format-time-string (cdr org-time-stamp-formats) (org-current-time))) | 9087 | (v-t (format-time-string (car org-time-stamp-formats) (org-current-time))) |
| 8347 | (v-u (concat "[" (substring v-t 1 -1) "]")) | 9088 | (v-T (format-time-string (cdr org-time-stamp-formats) (org-current-time))) |
| 8348 | (v-U (concat "[" (substring v-T 1 -1) "]")) | 9089 | (v-u (concat "[" (substring v-t 1 -1) "]")) |
| 8349 | (v-a annotation) ; defined in `remember-mode' | 9090 | (v-U (concat "[" (substring v-T 1 -1) "]")) |
| 8350 | (v-i initial) ; defined in `remember-mode' | 9091 | (v-a annotation) ; defined in `remember-mode' |
| 8351 | (v-n user-full-name) | 9092 | (v-i initial) ; defined in `remember-mode' |
| 8352 | ) | 9093 | (v-n user-full-name) |
| 8353 | (unless tpl (setq tpl "") (message "No template") (ding)) | 9094 | ) |
| 8354 | (insert tpl) (goto-char (point-min)) | 9095 | (unless tpl (setq tpl "") (message "No template") (ding)) |
| 8355 | (while (re-search-forward "%\\([tTuTai]\\)" nil t) | 9096 | (insert tpl) (goto-char (point-min)) |
| 8356 | (when (and initial (equal (match-string 0) "%i")) | 9097 | (while (re-search-forward "%\\([tTuTai]\\)" nil t) |
| 8357 | (save-match-data | 9098 | (when (and initial (equal (match-string 0) "%i")) |
| 8358 | (let* ((lead (buffer-substring | 9099 | (save-match-data |
| 8359 | (point-at-bol) (match-beginning 0)))) | 9100 | (let* ((lead (buffer-substring |
| 8360 | (setq v-i (mapconcat 'identity | 9101 | (point-at-bol) (match-beginning 0)))) |
| 9102 | (setq v-i (mapconcat 'identity | ||
| 8361 | (org-split-string initial "\n") | 9103 | (org-split-string initial "\n") |
| 8362 | (concat "\n" lead)))))) | 9104 | (concat "\n" lead)))))) |
| 8363 | (replace-match | 9105 | (replace-match |
| 8364 | (or (eval (intern (concat "v-" (match-string 1)))) "") | 9106 | (or (eval (intern (concat "v-" (match-string 1)))) "") |
| 8365 | t t)) | 9107 | t t)) |
| 8366 | (let ((org-startup-folded nil) | 9108 | (let ((org-startup-folded nil) |
| 8367 | (org-startup-with-deadline-check nil)) | 9109 | (org-startup-with-deadline-check nil)) |
| 8368 | (org-mode)) | 9110 | (org-mode)) |
| 8369 | (if (and file (string-match "\\S-" file) (not (file-directory-p file))) | 9111 | (if (and file (string-match "\\S-" file) (not (file-directory-p file))) |
| 8370 | (set (make-local-variable 'org-default-notes-file) file)) | 9112 | (set (make-local-variable 'org-default-notes-file) file)) |
| 8371 | (goto-char (point-min)) | 9113 | (goto-char (point-min)) |
| 8372 | (if (re-search-forward "%\\?" nil t) (replace-match "")) | 9114 | (if (re-search-forward "%\\?" nil t) (replace-match ""))) |
| 8373 | (set (make-local-variable 'org-finish-function) 'remember-buffer)))) | 9115 | (let ((org-startup-folded nil) |
| 9116 | (org-startup-with-deadline-check nil)) | ||
| 9117 | (org-mode))) | ||
| 9118 | (set (make-local-variable 'org-finish-function) 'remember-buffer)) | ||
| 8374 | 9119 | ||
| 8375 | ;;;###autoload | 9120 | ;;;###autoload |
| 8376 | (defun org-remember-handler () | 9121 | (defun org-remember-handler () |
| @@ -8439,6 +9184,9 @@ See also the variable `org-reverse-note-order'." | |||
| 8439 | (if (not visiting) | 9184 | (if (not visiting) |
| 8440 | (find-file-noselect file)) | 9185 | (find-file-noselect file)) |
| 8441 | (with-current-buffer (get-file-buffer file) | 9186 | (with-current-buffer (get-file-buffer file) |
| 9187 | (save-excursion (and (goto-char (point-min)) | ||
| 9188 | (not (re-search-forward "^\\* " nil t)) | ||
| 9189 | (insert "\n* Notes\n"))) | ||
| 8442 | (setq reversed (org-notes-order-reversed-p)) | 9190 | (setq reversed (org-notes-order-reversed-p)) |
| 8443 | (save-excursion | 9191 | (save-excursion |
| 8444 | (save-restriction | 9192 | (save-restriction |
| @@ -8866,7 +9614,7 @@ With argument TABLE-TYPE, go to the beginning of a table.el-type table." | |||
| 8866 | (if table-type org-table-any-border-regexp | 9614 | (if table-type org-table-any-border-regexp |
| 8867 | org-table-border-regexp) | 9615 | org-table-border-regexp) |
| 8868 | nil t)) | 9616 | nil t)) |
| 8869 | (error "Can't find beginning of table") | 9617 | (progn (goto-char (point-min)) (point)) |
| 8870 | (goto-char (match-beginning 0)) | 9618 | (goto-char (match-beginning 0)) |
| 8871 | (beginning-of-line 2) | 9619 | (beginning-of-line 2) |
| 8872 | (point)))) | 9620 | (point)))) |
| @@ -9213,7 +9961,7 @@ If TABLE-TYPE is non-nil, also check for table.el-type tables." | |||
| 9213 | "Please position cursor in a data line for column operations"))))) | 9961 | "Please position cursor in a data line for column operations"))))) |
| 9214 | 9962 | ||
| 9215 | (defun org-table-delete-column () | 9963 | (defun org-table-delete-column () |
| 9216 | "Delete a column into the table." | 9964 | "Delete a column from the table." |
| 9217 | (interactive) | 9965 | (interactive) |
| 9218 | (if (not (org-at-table-p)) | 9966 | (if (not (org-at-table-p)) |
| 9219 | (error "Not at a table")) | 9967 | (error "Not at a table")) |
| @@ -9352,7 +10100,7 @@ With prefix ARG, insert above the current line." | |||
| 9352 | In particular, this does handle wide and invisible characters." | 10100 | In particular, this does handle wide and invisible characters." |
| 9353 | (if (string-match "^[ \t]*|-" s) | 10101 | (if (string-match "^[ \t]*|-" s) |
| 9354 | ;; It's a hline, just map the characters | 10102 | ;; It's a hline, just map the characters |
| 9355 | (setq s (mapcar (lambda (x) (if (member x '(?| ?+)) ?| ?\ )) s)) | 10103 | (setq s (mapconcat (lambda (x) (if (member x '(?| ?+)) "|" " ")) s "")) |
| 9356 | (while (string-match "|\\([ \t]*?[^ \t\r\n|][^\r\n|]*\\)|" s) | 10104 | (while (string-match "|\\([ \t]*?[^ \t\r\n|][^\r\n|]*\\)|" s) |
| 9357 | (setq s (replace-match | 10105 | (setq s (replace-match |
| 9358 | (concat "|" (make-string (org-string-width (match-string 1 s)) | 10106 | (concat "|" (make-string (org-string-width (match-string 1 s)) |
| @@ -9401,7 +10149,7 @@ also in table column 3. The command will prompt for the sorting method | |||
| 9401 | (lambda (a b) (< (car a) (car b))) | 10149 | (lambda (a b) (< (car a) (car b))) |
| 9402 | (lambda (a b) (string< (car a) (car b))))) | 10150 | (lambda (a b) (string< (car a) (car b))))) |
| 9403 | (setq lns (mapcar (lambda(x) (cons (org-trim (substring x bcol ecol)) x)) | 10151 | (setq lns (mapcar (lambda(x) (cons (org-trim (substring x bcol ecol)) x)) |
| 9404 | (split-string (buffer-substring beg end) "\n"))) | 10152 | (org-split-string (buffer-substring beg end) "\n"))) |
| 9405 | (if numericp | 10153 | (if numericp |
| 9406 | (setq lns (mapcar (lambda(x) | 10154 | (setq lns (mapcar (lambda(x) |
| 9407 | (cons (string-to-number (car x)) (cdr x))) | 10155 | (cons (string-to-number (car x)) (cdr x))) |
| @@ -9937,7 +10685,7 @@ the current column, to avoid unnecessary parsing." | |||
| 9937 | "\n"))) | 10685 | "\n"))) |
| 9938 | 10686 | ||
| 9939 | (defun org-table-get-stored-formulas () | 10687 | (defun org-table-get-stored-formulas () |
| 9940 | "Return an alist with the t=stored formulas directly after current table." | 10688 | "Return an alist with the stored formulas directly after current table." |
| 9941 | (interactive) | 10689 | (interactive) |
| 9942 | (let (scol eq eq-alist strings string seen) | 10690 | (let (scol eq eq-alist strings string seen) |
| 9943 | (save-excursion | 10691 | (save-excursion |
| @@ -10217,7 +10965,7 @@ not overwrite the stored one." | |||
| 10217 | (org-table-get-formula equation (equal arg '(4))))) | 10965 | (org-table-get-formula equation (equal arg '(4))))) |
| 10218 | (n0 (org-table-current-column)) | 10966 | (n0 (org-table-current-column)) |
| 10219 | (modes (copy-sequence org-calc-default-modes)) | 10967 | (modes (copy-sequence org-calc-default-modes)) |
| 10220 | n form fmt x ev orig c) | 10968 | n form fmt x ev orig c lispp) |
| 10221 | ;; Parse the format string. Since we have a lot of modes, this is | 10969 | ;; Parse the format string. Since we have a lot of modes, this is |
| 10222 | ;; a lot of work. However, I think calc still uses most of the time. | 10970 | ;; a lot of work. However, I think calc still uses most of the time. |
| 10223 | (if (string-match ";" formula) | 10971 | (if (string-match ";" formula) |
| @@ -10252,7 +11000,8 @@ not overwrite the stored one." | |||
| 10252 | (lambda (x) (number-to-string (string-to-number x))) | 11000 | (lambda (x) (number-to-string (string-to-number x))) |
| 10253 | fields))) | 11001 | fields))) |
| 10254 | (setq ndown (1- ndown)) | 11002 | (setq ndown (1- ndown)) |
| 10255 | (setq form (copy-sequence formula)) | 11003 | (setq form (copy-sequence formula) |
| 11004 | lispp (equal (substring form 0 2) "'(")) | ||
| 10256 | ;; Insert the references to fields in same row | 11005 | ;; Insert the references to fields in same row |
| 10257 | (while (string-match "\\$\\([0-9]+\\)?" form) | 11006 | (while (string-match "\\$\\([0-9]+\\)?" form) |
| 10258 | (setq n (if (match-beginning 1) | 11007 | (setq n (if (match-beginning 1) |
| @@ -10262,7 +11011,9 @@ not overwrite the stored one." | |||
| 10262 | (unless x (error "Invalid field specifier \"%s\"" | 11011 | (unless x (error "Invalid field specifier \"%s\"" |
| 10263 | (match-string 0 form))) | 11012 | (match-string 0 form))) |
| 10264 | (if (equal x "") (setq x "0")) | 11013 | (if (equal x "") (setq x "0")) |
| 10265 | (setq form (replace-match (concat "(" x ")") t t form))) | 11014 | (setq form (replace-match |
| 11015 | (if lispp x (concat "(" x ")")) | ||
| 11016 | t t form))) | ||
| 10266 | ;; Insert ranges in current column | 11017 | ;; Insert ranges in current column |
| 10267 | (while (string-match "\\&[-I0-9]+" form) | 11018 | (while (string-match "\\&[-I0-9]+" form) |
| 10268 | (setq form (replace-match | 11019 | (setq form (replace-match |
| @@ -10270,8 +11021,14 @@ not overwrite the stored one." | |||
| 10270 | (org-table-get-vertical-vector (match-string 0 form) | 11021 | (org-table-get-vertical-vector (match-string 0 form) |
| 10271 | nil n0)) | 11022 | nil n0)) |
| 10272 | t t form))) | 11023 | t t form))) |
| 10273 | (setq ev (calc-eval (cons form modes) | 11024 | ;; (setq ev (calc-eval (cons form modes) |
| 10274 | (if org-table-formula-numbers-only 'num))) | 11025 | ;; FIXME (if org-table-formula-numbers-only 'num))) |
| 11026 | |||
| 11027 | (if lispp | ||
| 11028 | (setq ev (eval (eval (read form))) | ||
| 11029 | ev (if (numberp ev) (number-to-string ev) ev)) | ||
| 11030 | (setq ev (calc-eval (cons form modes) | ||
| 11031 | (if org-table-formula-numbers-only 'num)))) | ||
| 10275 | 11032 | ||
| 10276 | (when org-table-formula-debug | 11033 | (when org-table-formula-debug |
| 10277 | (with-output-to-temp-buffer "*Help*" | 11034 | (with-output-to-temp-buffer "*Help*" |
| @@ -10827,6 +11584,109 @@ overwritten, and the table is not marked as requiring realignment." | |||
| 10827 | 11584 | ||
| 10828 | (defconst org-level-max 20) | 11585 | (defconst org-level-max 20) |
| 10829 | 11586 | ||
| 11587 | (defvar org-export-html-preamble nil | ||
| 11588 | "Preamble, to be inserted just after <body>. Set by publishing functions.") | ||
| 11589 | (defvar org-export-html-postamble nil | ||
| 11590 | "Preamble, to be inserted just before </body>. Set by publishing functions.") | ||
| 11591 | (defvar org-export-html-auto-preamble t | ||
| 11592 | "Should default preamble be inserted? Set by publishing functions.") | ||
| 11593 | (defvar org-export-html-auto-postamble t | ||
| 11594 | "Should default postamble be inserted? Set by publishing functions.") | ||
| 11595 | |||
| 11596 | (defconst org-export-plist-vars | ||
| 11597 | '((:language . org-export-default-language) | ||
| 11598 | (:headline-levels . org-export-headline-levels) | ||
| 11599 | (:section-numbers . org-export-with-section-numbers) | ||
| 11600 | (:table-of-contents . org-export-with-toc) | ||
| 11601 | (:emphasize . org-export-with-emphasize) | ||
| 11602 | (:sub-superscript . org-export-with-sub-superscripts) | ||
| 11603 | (:TeX-macros . org-export-with-TeX-macros) | ||
| 11604 | (:fixed-width . org-export-with-fixed-width) | ||
| 11605 | (:timestamps . org-export-with-timestamps) | ||
| 11606 | (:tables . org-export-with-tables) | ||
| 11607 | (:table-auto-headline . org-export-highlight-first-table-line) | ||
| 11608 | (:style . org-export-html-style) | ||
| 11609 | (:convert-org-links . org-export-html-link-org-files-as-html) | ||
| 11610 | (:inline-images . org-export-html-inline-images) | ||
| 11611 | (:expand-quoted-html . org-export-html-expand) | ||
| 11612 | (:timestamp . org-export-html-with-timestamp) | ||
| 11613 | (:publishing-directory . org-export-publishing-directory) | ||
| 11614 | (:preamble . org-export-html-preamble) | ||
| 11615 | (:postamble . org-export-html-postamble) | ||
| 11616 | (:auto-preamble . org-export-html-auto-preamble) | ||
| 11617 | (:auto-postamble . org-export-html-auto-postamble) | ||
| 11618 | (:author . user-full-name) | ||
| 11619 | (:email . user-mail-address))) | ||
| 11620 | |||
| 11621 | (defun org-default-export-plist () | ||
| 11622 | "Return the property list with default settings for the export variables." | ||
| 11623 | (let ((l org-export-plist-vars) rtn e) | ||
| 11624 | (while (setq e (pop l)) | ||
| 11625 | (setq rtn (cons (car e) (cons (symbol-value (cdr e)) rtn)))) | ||
| 11626 | rtn)) | ||
| 11627 | |||
| 11628 | (defun org-infile-export-plist () | ||
| 11629 | "Return the property list with file-local settings for export." | ||
| 11630 | (save-excursion | ||
| 11631 | (goto-char 0) | ||
| 11632 | (let ((re (org-make-options-regexp | ||
| 11633 | '("TITLE" "AUTHOR" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE"))) | ||
| 11634 | (text nil) | ||
| 11635 | p key val text options) | ||
| 11636 | (while (re-search-forward re nil t) | ||
| 11637 | (setq key (org-match-string-no-properties 1) | ||
| 11638 | val (org-match-string-no-properties 2)) | ||
| 11639 | (cond | ||
| 11640 | ((string-equal key "TITLE") (setq p (plist-put p :title val))) | ||
| 11641 | ((string-equal key "AUTHOR")(setq p (plist-put p :author val))) | ||
| 11642 | ((string-equal key "EMAIL") (setq p (plist-put p :email val))) | ||
| 11643 | ((string-equal key "LANGUAGE") (setq p (plist-put p :language val))) | ||
| 11644 | ((string-equal key "TEXT") | ||
| 11645 | (setq text (if text (concat text "\n" val) val))) | ||
| 11646 | ((string-equal key "OPTIONS") (setq options val)))) | ||
| 11647 | (setq p (plist-put p :text text)) | ||
| 11648 | (when options | ||
| 11649 | (let ((op '(("H" . :headline-levels) | ||
| 11650 | ("num" . :section-numbers) | ||
| 11651 | ("toc" . :table-of-contents) | ||
| 11652 | ("\\n" . :preserve-breaks) | ||
| 11653 | ("@" . :expand-quoted-html) | ||
| 11654 | (":" . :fixed-width) | ||
| 11655 | ("|" . :tables) | ||
| 11656 | ("^" . :sub-superscript) | ||
| 11657 | ("*" . :emphasize) | ||
| 11658 | ("TeX" . :TeX-macros))) | ||
| 11659 | o) | ||
| 11660 | (while (setq o (pop op)) | ||
| 11661 | (if (string-match (concat (regexp-quote (car o)) | ||
| 11662 | ":\\([^ \t\n\r;,.]*\\)") | ||
| 11663 | options) | ||
| 11664 | (setq p (plist-put p (cdr o) | ||
| 11665 | (car (read-from-string | ||
| 11666 | (match-string 1 options))))))))) | ||
| 11667 | p))) | ||
| 11668 | |||
| 11669 | (defun org-combine-plists (&rest plists) | ||
| 11670 | "Create a single property list from all plists in PLISTS. | ||
| 11671 | The process starts by copying the last list, and then setting properties | ||
| 11672 | from the other lists. Settings in the first list are the most significant | ||
| 11673 | ones and overrule settings in the other lists." | ||
| 11674 | (let ((rtn (copy-sequence (pop plists))) | ||
| 11675 | p v ls) | ||
| 11676 | (while plists | ||
| 11677 | (setq ls (pop plists)) | ||
| 11678 | (while ls | ||
| 11679 | (setq p (pop ls) v (pop ls)) | ||
| 11680 | (setq rtn (plist-put rtn p v)))) | ||
| 11681 | rtn)) | ||
| 11682 | |||
| 11683 | (defun org-export-directory (type plist) | ||
| 11684 | (let* ((val (plist-get plist :publishing-directory)) | ||
| 11685 | (dir (if (listp val) | ||
| 11686 | (or (cdr (assoc type val)) ".") | ||
| 11687 | val))) | ||
| 11688 | dir)) | ||
| 11689 | |||
| 10830 | (defun org-export-find-first-heading-line (list) | 11690 | (defun org-export-find-first-heading-line (list) |
| 10831 | "Remove all lines from LIST which are before the first headline." | 11691 | "Remove all lines from LIST which are before the first headline." |
| 10832 | (let ((orig-list list) | 11692 | (let ((orig-list list) |
| @@ -11274,7 +12134,9 @@ The prefix ARG specifies how many levels of the outline should become | |||
| 11274 | underlined headlines. The default is 3." | 12134 | underlined headlines. The default is 3." |
| 11275 | (interactive "P") | 12135 | (interactive "P") |
| 11276 | (setq-default org-todo-line-regexp org-todo-line-regexp) | 12136 | (setq-default org-todo-line-regexp org-todo-line-regexp) |
| 11277 | (let* ((region | 12137 | (let* ((opt-plist (org-combine-plists (org-default-export-plist) |
| 12138 | (org-infile-export-plist))) | ||
| 12139 | (region | ||
| 11278 | (buffer-substring | 12140 | (buffer-substring |
| 11279 | (if (org-region-active-p) (region-beginning) (point-min)) | 12141 | (if (org-region-active-p) (region-beginning) (point-min)) |
| 11280 | (if (org-region-active-p) (region-end) (point-max)))) | 12142 | (if (org-region-active-p) (region-end) (point-max)))) |
| @@ -11287,17 +12149,23 @@ underlined headlines. The default is 3." | |||
| 11287 | (level 0) line txt | 12149 | (level 0) line txt |
| 11288 | (umax nil) | 12150 | (umax nil) |
| 11289 | (case-fold-search nil) | 12151 | (case-fold-search nil) |
| 11290 | (filename (concat (file-name-sans-extension buffer-file-name) | 12152 | (filename (concat (file-name-as-directory |
| 12153 | (org-export-directory :ascii opt-plist)) | ||
| 12154 | (file-name-sans-extension | ||
| 12155 | (file-name-nondirectory buffer-file-name)) | ||
| 11291 | ".txt")) | 12156 | ".txt")) |
| 11292 | (buffer (find-file-noselect filename)) | 12157 | (buffer (find-file-noselect filename)) |
| 11293 | (levels-open (make-vector org-level-max nil)) | 12158 | (levels-open (make-vector org-level-max nil)) |
| 12159 | (odd org-odd-levels-only) | ||
| 11294 | (date (format-time-string "%Y/%m/%d" (current-time))) | 12160 | (date (format-time-string "%Y/%m/%d" (current-time))) |
| 11295 | (time (format-time-string "%X" (org-current-time))) | 12161 | (time (format-time-string "%X" (org-current-time))) |
| 11296 | (author user-full-name) | 12162 | (author (plist-get opt-plist :author)) |
| 11297 | (title (buffer-name)) | 12163 | (title (or (plist-get opt-plist :title) |
| 12164 | (file-name-sans-extension | ||
| 12165 | (file-name-nondirectory buffer-file-name)))) | ||
| 11298 | (options nil) | 12166 | (options nil) |
| 11299 | (email user-mail-address) | 12167 | (email (plist-get opt-plist :email)) |
| 11300 | (language org-export-default-language) | 12168 | (language (plist-get opt-plist :language)) |
| 11301 | (text nil) | 12169 | (text nil) |
| 11302 | (todo nil) | 12170 | (todo nil) |
| 11303 | (lang-words nil)) | 12171 | (lang-words nil)) |
| @@ -11307,9 +12175,6 @@ underlined headlines. The default is 3." | |||
| 11307 | 12175 | ||
| 11308 | (find-file-noselect filename) | 12176 | (find-file-noselect filename) |
| 11309 | 12177 | ||
| 11310 | ;; Search for the export key lines | ||
| 11311 | (org-parse-key-lines) | ||
| 11312 | |||
| 11313 | (setq lang-words (or (assoc language org-export-language-setup) | 12178 | (setq lang-words (or (assoc language org-export-language-setup) |
| 11314 | (assoc "en" org-export-language-setup))) | 12179 | (assoc "en" org-export-language-setup))) |
| 11315 | (if org-export-ascii-show-new-buffer | 12180 | (if org-export-ascii-show-new-buffer |
| @@ -11317,7 +12182,13 @@ underlined headlines. The default is 3." | |||
| 11317 | (set-buffer buffer)) | 12182 | (set-buffer buffer)) |
| 11318 | (erase-buffer) | 12183 | (erase-buffer) |
| 11319 | (fundamental-mode) | 12184 | (fundamental-mode) |
| 11320 | (if options (org-parse-export-options options)) | 12185 | ;; create local variables for all options, to make sure all called |
| 12186 | ;; functions get the correct information | ||
| 12187 | (mapcar (lambda (x) | ||
| 12188 | (set (make-local-variable (cdr x)) | ||
| 12189 | (plist-get opt-plist (car x)))) | ||
| 12190 | org-export-plist-vars) | ||
| 12191 | (set (make-local-variable 'org-odd-levels-only) odd) | ||
| 11321 | (setq umax (if arg (prefix-numeric-value arg) | 12192 | (setq umax (if arg (prefix-numeric-value arg) |
| 11322 | org-export-headline-levels)) | 12193 | org-export-headline-levels)) |
| 11323 | 12194 | ||
| @@ -11347,7 +12218,8 @@ underlined headlines. The default is 3." | |||
| 11347 | level (org-tr-level level) | 12218 | level (org-tr-level level) |
| 11348 | txt (match-string 3 line) | 12219 | txt (match-string 3 line) |
| 11349 | todo | 12220 | todo |
| 11350 | (or (and (match-beginning 2) | 12221 | (or (and org-export-mark-todo-in-toc |
| 12222 | (match-beginning 2) | ||
| 11351 | (not (equal (match-string 2 line) | 12223 | (not (equal (match-string 2 line) |
| 11352 | org-done-string))) | 12224 | org-done-string))) |
| 11353 | ; TODO, not DONE | 12225 | ; TODO, not DONE |
| @@ -11390,6 +12262,19 @@ underlined headlines. The default is 3." | |||
| 11390 | (t (insert line "\n")))) | 12262 | (t (insert line "\n")))) |
| 11391 | (normal-mode) | 12263 | (normal-mode) |
| 11392 | (save-buffer) | 12264 | (save-buffer) |
| 12265 | ;; remove display and invisible chars | ||
| 12266 | (let (beg end s) | ||
| 12267 | (goto-char (point-min)) | ||
| 12268 | (while (setq beg (next-single-property-change (point) 'display)) | ||
| 12269 | (setq end (next-single-property-change beg 'display)) | ||
| 12270 | (delete-region beg end) | ||
| 12271 | (goto-char beg) | ||
| 12272 | (insert "=>")) | ||
| 12273 | (goto-char (point-min)) | ||
| 12274 | (while (setq beg (next-single-property-change (point) 'org-cwidth)) | ||
| 12275 | (setq end (next-single-property-change beg 'org-cwidth)) | ||
| 12276 | (delete-region beg end) | ||
| 12277 | (goto-char beg))) | ||
| 11393 | (goto-char (point-min)))) | 12278 | (goto-char (point-min)))) |
| 11394 | 12279 | ||
| 11395 | (defun org-search-todo-below (line lines level) | 12280 | (defun org-search-todo-below (line lines level) |
| @@ -11441,38 +12326,54 @@ underlined headlines. The default is 3." | |||
| 11441 | (setq title (concat (org-section-number level) " " title))) | 12326 | (setq title (concat (org-section-number level) " " title))) |
| 11442 | (insert title "\n" (make-string (string-width title) char) "\n")))) | 12327 | (insert title "\n" (make-string (string-width title) char) "\n")))) |
| 11443 | 12328 | ||
| 11444 | (defun org-export-copy-visible () | 12329 | (defun org-export-visible (type arg) |
| 11445 | "Copy the visible part of the buffer to another buffer, for printing. | 12330 | "Create a copy of the visible part of the current buffer, and export it. |
| 11446 | Also removes the first line of the buffer if it specifies a mode, | 12331 | The copy is created in a temporary buffer and removed after use. |
| 11447 | and all options lines." | 12332 | TYPE is the final key (as a string) of the `C-c C-x' key sequence that will |
| 11448 | (interactive) | 12333 | run the export command - in interactive use, the command prompts for this |
| 11449 | (let* ((filename (concat (file-name-sans-extension buffer-file-name) | 12334 | key. As a special case, if the you type SPC at the prompt, the temporary |
| 11450 | ".txt")) | 12335 | org-mode file will not be removed but presented to you so that you can |
| 11451 | (buffer (find-file-noselect filename)) | 12336 | continue to use it. The prefix arg ARG is passed through to the exporting |
| 11452 | (ore (concat | 12337 | command." |
| 11453 | (org-make-options-regexp | 12338 | (interactive |
| 11454 | '("CATEGORY" "SEQ_TODO" "PRI_TODO" "TYP_TODO" | 12339 | (list (progn |
| 11455 | "STARTUP" "ARCHIVE" | 12340 | (message "Export visible: [a]SCII [h]tml [b]rowse HTML [x]OXO [ ]keep buffer") |
| 11456 | "TITLE" "AUTHOR" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE")) | 12341 | (char-to-string (read-char-exclusive))) |
| 11457 | (if org-noutline-p "\\(\n\\|$\\)" ""))) | 12342 | current-prefix-arg)) |
| 12343 | (if (not (member type '("a" "\C-a" "b" "\C-b" "h" "x" " "))) | ||
| 12344 | (error "Invalid export key")) | ||
| 12345 | (let* ((binding (key-binding (concat "\C-c\C-x" type))) | ||
| 12346 | (keepp (equal type " ")) | ||
| 12347 | (file buffer-file-name) | ||
| 12348 | (buffer (get-buffer-create "*Org Export Visible*")) | ||
| 11458 | s e) | 12349 | s e) |
| 11459 | (with-current-buffer buffer | 12350 | (with-current-buffer buffer (erase-buffer)) |
| 11460 | (erase-buffer) | ||
| 11461 | (text-mode)) | ||
| 11462 | (save-excursion | 12351 | (save-excursion |
| 11463 | (setq s (goto-char (point-min))) | 12352 | (setq s (goto-char (point-min))) |
| 11464 | (while (not (= (point) (point-max))) | 12353 | (while (not (= (point) (point-max))) |
| 11465 | (goto-char (org-find-invisible)) | 12354 | (goto-char (org-find-invisible)) |
| 11466 | (append-to-buffer buffer s (point)) | 12355 | (append-to-buffer buffer s (point)) |
| 11467 | (setq s (goto-char (org-find-visible))))) | 12356 | (setq s (goto-char (org-find-visible)))) |
| 11468 | (switch-to-buffer-other-window buffer) | 12357 | (goto-char (point-min)) |
| 11469 | (newline) | 12358 | (unless keepp |
| 11470 | (goto-char (point-min)) | 12359 | ;; Copy all comment lines to the end, to make sure #+ settings are |
| 11471 | (if (looking-at ".*-\\*- mode:.*\n") | 12360 | ;; still available for the second export step. Kind of a hack, but |
| 11472 | (replace-match "")) | 12361 | ;; does do the trick. |
| 11473 | (while (re-search-forward ore nil t) | 12362 | (if (looking-at "#[^\r\n]*") |
| 11474 | (replace-match "")) | 12363 | (append-to-buffer buffer (match-beginning 0) (1+ (match-end 0)))) |
| 11475 | (goto-char (point-min)))) | 12364 | (while (re-search-forward "[\n\r]#[^\n\r]*" nil t) |
| 12365 | (append-to-buffer buffer (1+ (match-beginning 0)) | ||
| 12366 | (min (point-max) (1+ (match-end 0)))))) | ||
| 12367 | (set-buffer buffer) | ||
| 12368 | (let ((buffer-file-name file) | ||
| 12369 | (org-inhibit-startup t)) | ||
| 12370 | (org-mode) | ||
| 12371 | (show-all) | ||
| 12372 | (unless keepp (funcall binding arg)))) | ||
| 12373 | (if (not keepp) | ||
| 12374 | (kill-buffer buffer) | ||
| 12375 | (switch-to-buffer-other-window buffer) | ||
| 12376 | (goto-char (point-min))))) | ||
| 11476 | 12377 | ||
| 11477 | (defun org-find-visible () | 12378 | (defun org-find-visible () |
| 11478 | (if (featurep 'noutline) | 12379 | (if (featurep 'noutline) |
| @@ -11506,7 +12407,8 @@ Does include HTML export options as well as TODO and CATEGORY stuff." | |||
| 11506 | #+CATEGORY: %s | 12407 | #+CATEGORY: %s |
| 11507 | #+SEQ_TODO: %s | 12408 | #+SEQ_TODO: %s |
| 11508 | #+TYP_TODO: %s | 12409 | #+TYP_TODO: %s |
| 11509 | #+STARTUP: %s %s %s %s %s | 12410 | #+STARTUP: %s %s %s %s %s %s |
| 12411 | #+TAGS: %s | ||
| 11510 | #+ARCHIVE: %s | 12412 | #+ARCHIVE: %s |
| 11511 | " | 12413 | " |
| 11512 | (buffer-name) (user-full-name) user-mail-address org-export-default-language | 12414 | (buffer-name) (user-full-name) user-mail-address org-export-default-language |
| @@ -11533,6 +12435,8 @@ Does include HTML export options as well as TODO and CATEGORY stuff." | |||
| 11533 | (if org-odd-levels-only "odd" "oddeven") | 12435 | (if org-odd-levels-only "odd" "oddeven") |
| 11534 | (if org-hide-leading-stars "hidestars" "showstars") | 12436 | (if org-hide-leading-stars "hidestars" "showstars") |
| 11535 | (if org-startup-align-all-tables "align" "noalign") | 12437 | (if org-startup-align-all-tables "align" "noalign") |
| 12438 | (if org-log-done "logging" "nologging") | ||
| 12439 | (if org-tag-alist (mapconcat 'car org-tag-alist " ") "") | ||
| 11536 | org-archive-location | 12440 | org-archive-location |
| 11537 | )) | 12441 | )) |
| 11538 | 12442 | ||
| @@ -11606,16 +12510,23 @@ emacs --batch | |||
| 11606 | --visit=MyFile --funcall org-export-as-html-batch" | 12510 | --visit=MyFile --funcall org-export-as-html-batch" |
| 11607 | (org-export-as-html org-export-headline-levels 'hidden)) | 12511 | (org-export-as-html org-export-headline-levels 'hidden)) |
| 11608 | 12512 | ||
| 11609 | (defun org-export-as-html (arg &optional hidden) | 12513 | (defun org-export-as-html (arg &optional hidden ext-plist) |
| 11610 | "Export the outline as a pretty HTML file. | 12514 | "Export the outline as a pretty HTML file. |
| 11611 | If there is an active region, export only the region. | 12515 | If there is an active region, export only the region. |
| 11612 | The prefix ARG specifies how many levels of the outline should become | 12516 | The prefix ARG specifies how many levels of the outline should become |
| 11613 | headlines. The default is 3. Lower levels will become bulleted lists." | 12517 | headlines. The default is 3. Lower levels will become bulleted lists. |
| 12518 | When HIDDEN is non-nil, don't display the HTML buffer. | ||
| 12519 | EXT-PLIST is a property list with external parameters overriding | ||
| 12520 | org-mode's default settings, but still inferior to file-local settings." | ||
| 11614 | (interactive "P") | 12521 | (interactive "P") |
| 11615 | (setq-default org-todo-line-regexp org-todo-line-regexp) | 12522 | (setq-default org-todo-line-regexp org-todo-line-regexp) |
| 11616 | (setq-default org-deadline-line-regexp org-deadline-line-regexp) | 12523 | (setq-default org-deadline-line-regexp org-deadline-line-regexp) |
| 11617 | (setq-default org-done-string org-done-string) | 12524 | (setq-default org-done-string org-done-string) |
| 11618 | (let* ((style org-export-html-style) | 12525 | (let* ((opt-plist (org-combine-plists (org-default-export-plist) |
| 12526 | ext-plist | ||
| 12527 | (org-infile-export-plist))) | ||
| 12528 | |||
| 12529 | (style (plist-get opt-plist :style)) | ||
| 11619 | (odd org-odd-levels-only) | 12530 | (odd org-odd-levels-only) |
| 11620 | (region-p (org-region-active-p)) | 12531 | (region-p (org-region-active-p)) |
| 11621 | (region | 12532 | (region |
| @@ -11629,26 +12540,31 @@ headlines. The default is 3. Lower levels will become bulleted lists." | |||
| 11629 | (lines (org-export-find-first-heading-line all_lines)) | 12540 | (lines (org-export-find-first-heading-line all_lines)) |
| 11630 | (level 0) (line "") (origline "") txt todo | 12541 | (level 0) (line "") (origline "") txt todo |
| 11631 | (umax nil) | 12542 | (umax nil) |
| 11632 | (filename (concat (file-name-sans-extension buffer-file-name) | 12543 | (filename (concat (file-name-as-directory |
| 11633 | ".html")) | 12544 | (org-export-directory :html opt-plist)) |
| 12545 | (file-name-sans-extension | ||
| 12546 | (file-name-nondirectory buffer-file-name)) | ||
| 12547 | ".html")) | ||
| 11634 | (buffer (find-file-noselect filename)) | 12548 | (buffer (find-file-noselect filename)) |
| 11635 | (levels-open (make-vector org-level-max nil)) | 12549 | (levels-open (make-vector org-level-max nil)) |
| 11636 | (date (format-time-string "%Y/%m/%d" (current-time))) | 12550 | (date (format-time-string "%Y/%m/%d" (current-time))) |
| 11637 | (time (format-time-string "%X" (org-current-time))) | 12551 | (time (format-time-string "%X" (org-current-time))) |
| 11638 | (author user-full-name) | 12552 | (author (plist-get opt-plist :author)) |
| 11639 | (title (buffer-name)) | 12553 | (title (or (plist-get opt-plist :title) |
| 11640 | (options nil) | 12554 | (file-name-sans-extension |
| 11641 | (quote-re (concat "^\\*+[ \t]*" org-quote-string "\\>")) | 12555 | (file-name-nondirectory buffer-file-name)))) |
| 12556 | (quote-re0 (concat "^[ \t]*" org-quote-string "\\>")) | ||
| 12557 | (quote-re (concat "^\\(\\*+\\)\\([ \t]*" org-quote-string "\\>\\)")) | ||
| 11642 | (inquote nil) | 12558 | (inquote nil) |
| 11643 | (infixed nil) | 12559 | (infixed nil) |
| 11644 | (in-local-list nil) | 12560 | (in-local-list nil) |
| 11645 | (local-list-num nil) | 12561 | (local-list-num nil) |
| 11646 | (local-list-indent nil) | 12562 | (local-list-indent nil) |
| 11647 | (llt org-plain-list-ordered-item-terminator) | 12563 | (llt org-plain-list-ordered-item-terminator) |
| 11648 | (email user-mail-address) | 12564 | (email (plist-get opt-plist :email)) |
| 11649 | (language org-export-default-language) | 12565 | (language (plist-get opt-plist :language)) |
| 11650 | (text nil) | 12566 | (text (plist-get opt-plist :text)) |
| 11651 | (lang-words nil) | 12567 | (lang-words nil) |
| 11652 | (target-alist nil) tg | 12568 | (target-alist nil) tg |
| 11653 | (head-count 0) cnt | 12569 | (head-count 0) cnt |
| 11654 | (start 0) | 12570 | (start 0) |
| @@ -11663,15 +12579,14 @@ headlines. The default is 3. Lower levels will become bulleted lists." | |||
| 11663 | table-open type | 12579 | table-open type |
| 11664 | table-buffer table-orig-buffer | 12580 | table-buffer table-orig-buffer |
| 11665 | ind start-is-num starter | 12581 | ind start-is-num starter |
| 11666 | rpl path desc desc1 desc2 link | 12582 | rpl path desc descp desc1 desc2 link |
| 11667 | ) | 12583 | ) |
| 11668 | (message "Exporting...") | 12584 | (message "Exporting...") |
| 11669 | 12585 | ||
| 11670 | (setq org-last-level 1) | 12586 | (setq org-last-level 1) |
| 11671 | (org-init-section-numbers) | 12587 | (org-init-section-numbers) |
| 11672 | 12588 | ||
| 11673 | ;; Search for the export key lines | 12589 | ;; Get the language-dependent settings |
| 11674 | (org-parse-key-lines) | ||
| 11675 | (setq lang-words (or (assoc language org-export-language-setup) | 12590 | (setq lang-words (or (assoc language org-export-language-setup) |
| 11676 | (assoc "en" org-export-language-setup))) | 12591 | (assoc "en" org-export-language-setup))) |
| 11677 | 12592 | ||
| @@ -11683,7 +12598,12 @@ headlines. The default is 3. Lower levels will become bulleted lists." | |||
| 11683 | (fundamental-mode) | 12598 | (fundamental-mode) |
| 11684 | (let ((case-fold-search nil) | 12599 | (let ((case-fold-search nil) |
| 11685 | (org-odd-levels-only odd)) | 12600 | (org-odd-levels-only odd)) |
| 11686 | (if options (org-parse-export-options options)) | 12601 | ;; create local variables for all options, to make sure all called |
| 12602 | ;; functions get the correct information | ||
| 12603 | (mapcar (lambda (x) | ||
| 12604 | (set (make-local-variable (cdr x)) | ||
| 12605 | (plist-get opt-plist (car x)))) | ||
| 12606 | org-export-plist-vars) | ||
| 11687 | (setq umax (if arg (prefix-numeric-value arg) | 12607 | (setq umax (if arg (prefix-numeric-value arg) |
| 11688 | org-export-headline-levels)) | 12608 | org-export-headline-levels)) |
| 11689 | 12609 | ||
| @@ -11702,15 +12622,21 @@ headlines. The default is 3. Lower levels will become bulleted lists." | |||
| 11702 | " | 12622 | " |
| 11703 | language (org-html-expand title) (or charset "iso-8859-1") | 12623 | language (org-html-expand title) (or charset "iso-8859-1") |
| 11704 | date time author style)) | 12624 | date time author style)) |
| 11705 | (if title (insert (concat "<H1 class=\"title\">" | 12625 | |
| 11706 | (org-html-expand title) "</H1>\n"))) | 12626 | |
| 11707 | (if author (insert (concat (nth 1 lang-words) ": " author "\n"))) | 12627 | (insert (or (plist-get opt-plist :preamble) "")) |
| 11708 | (if email (insert (concat "<a href=\"mailto:" email "\"><" | 12628 | |
| 11709 | email "></a>\n"))) | 12629 | (when (plist-get opt-plist :auto-preamble) |
| 11710 | (if (or author email) (insert "<br>\n")) | 12630 | (if title (insert (concat "<H1 class=\"title\">" |
| 11711 | (if (and date time) (insert (concat (nth 2 lang-words) ": " | 12631 | (org-html-expand title) "</H1>\n"))) |
| 11712 | date " " time "<br>\n"))) | 12632 | ; (if author (insert (concat (nth 1 lang-words) ": " author "\n"))) |
| 11713 | (if text (insert (concat "<p>\n" (org-html-expand text)))) | 12633 | ; (if email (insert (concat "<a href=\"mailto:" email "\"><" |
| 12634 | ; email "></a>\n"))) | ||
| 12635 | ; (if (or author email) (insert "<br>\n")) | ||
| 12636 | ; (if (and date time) (insert (concat (nth 2 lang-words) ": " | ||
| 12637 | ; date " " time "<br>\n"))) | ||
| 12638 | (if text (insert (concat "<p>\n" (org-html-expand text))))) | ||
| 12639 | |||
| 11714 | (if org-export-with-toc | 12640 | (if org-export-with-toc |
| 11715 | (progn | 12641 | (progn |
| 11716 | (insert (format "<H2>%s</H2>\n" (nth 3 lang-words))) | 12642 | (insert (format "<H2>%s</H2>\n" (nth 3 lang-words))) |
| @@ -11724,9 +12650,11 @@ headlines. The default is 3. Lower levels will become bulleted lists." | |||
| 11724 | level (org-tr-level level) | 12650 | level (org-tr-level level) |
| 11725 | txt (save-match-data | 12651 | txt (save-match-data |
| 11726 | (org-html-expand | 12652 | (org-html-expand |
| 11727 | (match-string 3 line))) | 12653 | (org-html-cleanup-toc-line |
| 12654 | (match-string 3 line)))) | ||
| 11728 | todo | 12655 | todo |
| 11729 | (or (and (match-beginning 2) | 12656 | (or (and org-export-mark-todo-in-toc |
| 12657 | (match-beginning 2) | ||
| 11730 | (not (equal (match-string 2 line) | 12658 | (not (equal (match-string 2 line) |
| 11731 | org-done-string))) | 12659 | org-done-string))) |
| 11732 | ; TODO, not DONE | 12660 | ; TODO, not DONE |
| @@ -11785,7 +12713,7 @@ headlines. The default is 3. Lower levels will become bulleted lists." | |||
| 11785 | (catch 'nextline | 12713 | (catch 'nextline |
| 11786 | 12714 | ||
| 11787 | ;; end of quote section? | 12715 | ;; end of quote section? |
| 11788 | (when (and inquote (string-match "^\\*+" line)) | 12716 | (when (and inquote (string-match "^\\*+" line)) |
| 11789 | (insert "</pre>\n") | 12717 | (insert "</pre>\n") |
| 11790 | (setq inquote nil)) | 12718 | (setq inquote nil)) |
| 11791 | ;; inside a quote section? | 12719 | ;; inside a quote section? |
| @@ -11829,8 +12757,11 @@ headlines. The default is 3. Lower levels will become bulleted lists." | |||
| 11829 | "\" class=\"target\">" (match-string 1 line) "@</a> ") | 12757 | "\" class=\"target\">" (match-string 1 line) "@</a> ") |
| 11830 | t t line))))) | 12758 | t t line))))) |
| 11831 | 12759 | ||
| 12760 | (setq line (org-html-handle-time-stamps line)) | ||
| 12761 | |||
| 11832 | ;; replace "&" by "&", "<" and ">" by "<" and ">" | 12762 | ;; replace "&" by "&", "<" and ">" by "<" and ">" |
| 11833 | ;; handle @<..> HTML tags (replace "@>..<" by "<..>") | 12763 | ;; handle @<..> HTML tags (replace "@>..<" by "<..>") |
| 12764 | ;; Also handle sub_superscripts and checkboxes FIXME | ||
| 11834 | (setq line (org-html-expand line)) | 12765 | (setq line (org-html-expand line)) |
| 11835 | 12766 | ||
| 11836 | ;; Format the links | 12767 | ;; Format the links |
| @@ -11841,7 +12772,9 @@ headlines. The default is 3. Lower levels will become bulleted lists." | |||
| 11841 | (setq path (match-string 3 line)) | 12772 | (setq path (match-string 3 line)) |
| 11842 | (setq desc1 (if (match-end 5) (match-string 5 line)) | 12773 | (setq desc1 (if (match-end 5) (match-string 5 line)) |
| 11843 | desc2 (if (match-end 2) (concat type ":" path) path) | 12774 | desc2 (if (match-end 2) (concat type ":" path) path) |
| 12775 | descp (and desc1 (not (equal desc1 desc2))) | ||
| 11844 | desc (or desc1 desc2)) | 12776 | desc (or desc1 desc2)) |
| 12777 | ;; FIXME: do we need to unescape here somewhere? | ||
| 11845 | (cond | 12778 | (cond |
| 11846 | ((equal type "internal") | 12779 | ((equal type "internal") |
| 11847 | (setq rpl | 12780 | (setq rpl |
| @@ -11877,12 +12810,18 @@ headlines. The default is 3. Lower levels will become bulleted lists." | |||
| 11877 | (not (string-match "^/.*/$" search))) | 12810 | (not (string-match "^/.*/$" search))) |
| 11878 | (setq thefile (concat thefile "#" | 12811 | (setq thefile (concat thefile "#" |
| 11879 | (org-solidify-link-text | 12812 | (org-solidify-link-text |
| 11880 | (org-link-unescape search))))))) | 12813 | (org-link-unescape search))))) |
| 11881 | (setq rpl (if (and org-export-html-inline-images | 12814 | (when (string-match "^file:" desc) |
| 11882 | file-is-image-p) | 12815 | (setq desc (replace-match "" t t desc)) |
| 12816 | (if (string-match "\\.org$" desc) | ||
| 12817 | (setq desc (replace-match "" t t desc)))))) | ||
| 12818 | (setq rpl (if (and file-is-image-p | ||
| 12819 | (or (eq t org-export-html-inline-images) | ||
| 12820 | (and org-export-html-inline-images | ||
| 12821 | (not descp)))) | ||
| 11883 | (concat "<img src=\"" thefile "\"/>") | 12822 | (concat "<img src=\"" thefile "\"/>") |
| 11884 | (concat "<a href=\"" thefile "\">" desc "</a>"))))) | 12823 | (concat "<a href=\"" thefile "\">" desc "</a>"))))) |
| 11885 | ((member type '("bbdb" "vm" "wl" "mhe" "rmail" "gnus" "shell")) | 12824 | ((member type '("bbdb" "vm" "wl" "mhe" "rmail" "gnus" "shell" "info" "elisp")) |
| 11886 | (setq rpl (concat "<i><" type ":" | 12825 | (setq rpl (concat "<i><" type ":" |
| 11887 | (save-match-data (org-link-unescape path)) | 12826 | (save-match-data (org-link-unescape path)) |
| 11888 | "></i>")))) | 12827 | "></i>")))) |
| @@ -11898,20 +12837,13 @@ headlines. The default is 3. Lower levels will become bulleted lists." | |||
| 11898 | (setq line (replace-match "<span class=\"todo\">\\2</span>" | 12837 | (setq line (replace-match "<span class=\"todo\">\\2</span>" |
| 11899 | nil nil line 2)))) | 12838 | nil nil line 2)))) |
| 11900 | 12839 | ||
| 11901 | ;; DEADLINES | ||
| 11902 | (if (string-match org-deadline-line-regexp line) | ||
| 11903 | (progn | ||
| 11904 | (if (save-match-data | ||
| 11905 | (string-match "<a href" | ||
| 11906 | (substring line 0 (match-beginning 0)))) | ||
| 11907 | nil ; Don't do the replacement - it is inside a link | ||
| 11908 | (setq line (replace-match "<span class=\"deadline\">\\&</span>" | ||
| 11909 | nil nil line 1))))) | ||
| 11910 | (cond | 12840 | (cond |
| 11911 | ((string-match "^\\(\\*+\\)[ \t]*\\(.*\\)" line) | 12841 | ((string-match "^\\(\\*+\\)[ \t]*\\(.*\\)" line) |
| 11912 | ;; This is a headline | 12842 | ;; This is a headline |
| 11913 | (setq level (org-tr-level (- (match-end 1) (match-beginning 1))) | 12843 | (setq level (org-tr-level (- (match-end 1) (match-beginning 1))) |
| 11914 | txt (match-string 2 line)) | 12844 | txt (match-string 2 line)) |
| 12845 | (if (string-match quote-re0 txt) | ||
| 12846 | (setq txt (replace-match "" t t txt))) | ||
| 11915 | (if (<= level umax) (setq head-count (+ head-count 1))) | 12847 | (if (<= level umax) (setq head-count (+ head-count 1))) |
| 11916 | (when in-local-list | 12848 | (when in-local-list |
| 11917 | ;; Close any local lists before inserting a new header line | 12849 | ;; Close any local lists before inserting a new header line |
| @@ -11945,16 +12877,17 @@ headlines. The default is 3. Lower levels will become bulleted lists." | |||
| 11945 | (insert (org-format-table-html table-buffer table-orig-buffer)))) | 12877 | (insert (org-format-table-html table-buffer table-orig-buffer)))) |
| 11946 | (t | 12878 | (t |
| 11947 | ;; Normal lines | 12879 | ;; Normal lines |
| 11948 | (when (and (string-match | 12880 | (when (string-match |
| 11949 | (cond | 12881 | (cond |
| 11950 | ((eq llt t) "^\\([ \t]*\\)\\(\\([-+*]\\)\\|\\([0-9]+[.)]\\)\\)?\\( +[^ \t\n\r]\\|[ \t]*$\\)") | 12882 | ((eq llt t) "^\\([ \t]*\\)\\(\\([-+*]\\)\\|\\([0-9]+[.)]\\) \\)?\\( *[^ \t\n\r]\\|[ \t]*$\\)") |
| 11951 | ((= llt ?.) "^\\([ \t]*\\)\\(\\([-+*]\\)\\|\\([0-9]+\\.\\)\\)?\\( +[^ \t\n\r]\\|[ \t]*$\\)") | 12883 | ((= llt ?.) "^\\([ \t]*\\)\\(\\([-+*]\\)\\|\\([0-9]+\\.\\) \\)?\\( *[^ \t\n\r]\\|[ \t]*$\\)") |
| 11952 | ((= llt ?\)) "^\\( \t]*\\)\\(\\([-+*]\\)\\|\\([0-9]+)\\)\\)?\\( +[^ \t\n\r]\\|[ \t]*$\\)") | 12884 | ((= llt ?\)) "^\\( \t]*\\)\\(\\([-+*]\\)\\|\\([0-9]+)\\) \\)?\\( *[^ \t\n\r]\\|[ \t]*$\\)") |
| 11953 | (t (error "Invalid value of `org-plain-list-ordered-item-terminator'"))) | 12885 | (t (error "Invalid value of `org-plain-list-ordered-item-terminator'"))) |
| 11954 | line)) | 12886 | line) |
| 11955 | (setq ind (org-get-string-indentation line) | 12887 | (setq ind (org-get-string-indentation line) |
| 11956 | start-is-num (match-beginning 4) | 12888 | start-is-num (match-beginning 4) |
| 11957 | starter (if (match-beginning 2) (match-string 2 line)) | 12889 | starter (if (match-beginning 2) |
| 12890 | (substring (match-string 2 line) 0 -1)) | ||
| 11958 | line (substring line (match-beginning 5))) | 12891 | line (substring line (match-beginning 5))) |
| 11959 | (unless (string-match "[^ \t]" line) | 12892 | (unless (string-match "[^ \t]" line) |
| 11960 | ;; empty line. Pretend indentation is large. | 12893 | ;; empty line. Pretend indentation is large. |
| @@ -11977,15 +12910,46 @@ headlines. The default is 3. Lower levels will become bulleted lists." | |||
| 11977 | (setq in-local-list t)) | 12910 | (setq in-local-list t)) |
| 11978 | (starter | 12911 | (starter |
| 11979 | ;; continue current list | 12912 | ;; continue current list |
| 11980 | (insert "<li>\n")))) | 12913 | (insert "<li>\n"))) |
| 12914 | (if (string-match "^[ \t]*\\[\\([X ]\\)\\]" line) | ||
| 12915 | (setq line | ||
| 12916 | (replace-match | ||
| 12917 | (if (equal (match-string 1 line) "X") | ||
| 12918 | "<b>[X]</b>" | ||
| 12919 | "<b>[<span style=\"visibility:hidden;\">X</span>]</b>") | ||
| 12920 | t t line)))) | ||
| 12921 | |||
| 11981 | ;; Empty lines start a new paragraph. If hand-formatted lists | 12922 | ;; Empty lines start a new paragraph. If hand-formatted lists |
| 11982 | ;; are not fully interpreted, lines starting with "-", "+", "*" | 12923 | ;; are not fully interpreted, lines starting with "-", "+", "*" |
| 11983 | ;; also start a new paragraph. | 12924 | ;; also start a new paragraph. |
| 11984 | (if (string-match "^ [-+*]-\\|^[ \t]*$" line) (insert "<p>")) | 12925 | (if (string-match "^ [-+*]-\\|^[ \t]*$" line) (insert "<p>")) |
| 11985 | (insert line (if org-export-preserve-breaks "<br>\n" "\n")))) | 12926 | (insert line (if org-export-preserve-breaks "<br>\n" "\n")))) |
| 11986 | )) | 12927 | )) |
| 12928 | |||
| 12929 | ;; Properly close all local lists and other lists | ||
| 12930 | (when inquote (insert "</pre>\n")) | ||
| 12931 | (when in-local-list | ||
| 12932 | ;; Close any local lists before inserting a new header line | ||
| 12933 | (while local-list-num | ||
| 12934 | (insert (if (car local-list-num) "</ol>\n" "</ul>")) | ||
| 12935 | (pop local-list-num)) | ||
| 12936 | (setq local-list-indent nil | ||
| 12937 | in-local-list nil)) | ||
| 12938 | (org-html-level-start 1 nil umax | ||
| 12939 | (and org-export-with-toc (<= level umax)) | ||
| 12940 | head-count) | ||
| 12941 | |||
| 12942 | (when (plist-get opt-plist :auto-postamble) | ||
| 12943 | (if author (insert (concat (nth 1 lang-words) ": " author "\n"))) | ||
| 12944 | (if email (insert (concat "<a href=\"mailto:" email "\"><" | ||
| 12945 | email "></a>\n"))) | ||
| 12946 | (if (or author email) (insert "<br>\n")) | ||
| 12947 | (if (and date time) (insert (concat (nth 2 lang-words) ": " | ||
| 12948 | date " " time "<br>\n")))) | ||
| 12949 | |||
| 11987 | (if org-export-html-with-timestamp | 12950 | (if org-export-html-with-timestamp |
| 11988 | (insert org-export-html-html-helper-timestamp)) | 12951 | (insert org-export-html-html-helper-timestamp)) |
| 12952 | (insert (or (plist-get opt-plist :postamble) "")) | ||
| 11989 | (insert "</body>\n</html>\n") | 12953 | (insert "</body>\n</html>\n") |
| 11990 | (normal-mode) | 12954 | (normal-mode) |
| 11991 | (save-buffer) | 12955 | (save-buffer) |
| @@ -12140,6 +13104,30 @@ But it has the disadvantage, that Org-mode's HTML conversions cannot be used." | |||
| 12140 | (set-buffer " org-tmp2 ") | 13104 | (set-buffer " org-tmp2 ") |
| 12141 | (buffer-substring (point-min) (point-max)))) | 13105 | (buffer-substring (point-min) (point-max)))) |
| 12142 | 13106 | ||
| 13107 | (defun org-html-handle-time-stamps (s) | ||
| 13108 | "Format time stamps in string S, or remove them." | ||
| 13109 | (let (r b) | ||
| 13110 | (while (string-match org-maybe-keyword-time-regexp s) | ||
| 13111 | (or b (setq b (substring s 0 (match-beginning 0)))) | ||
| 13112 | (if (not org-export-with-timestamps) | ||
| 13113 | (setq r (concat r (substring s 0 (match-beginning 0))) | ||
| 13114 | s (substring s (match-end 0))) | ||
| 13115 | (setq r (concat | ||
| 13116 | r (substring s 0 (match-beginning 0)) | ||
| 13117 | (if (match-end 1) | ||
| 13118 | (format "@<span class=\"timestamp-kwd\">%s @</span>" | ||
| 13119 | (match-string 1 s))) | ||
| 13120 | (format " @<span class=\"timestamp\">%s@</span>" | ||
| 13121 | (substring (match-string 3 s) 1 -1))) | ||
| 13122 | s (substring s (match-end 0))))) | ||
| 13123 | ;; Line break of line started and ended with time stamp stuff | ||
| 13124 | (if (not r) | ||
| 13125 | s | ||
| 13126 | (setq r (concat r s)) | ||
| 13127 | (unless (string-match "\\S-" (concat b s)) | ||
| 13128 | (setq r (concat r "@<br>"))) | ||
| 13129 | r))) | ||
| 13130 | |||
| 12143 | (defun org-html-protect (s) | 13131 | (defun org-html-protect (s) |
| 12144 | ;; convert & to &, < to < and > to > | 13132 | ;; convert & to &, < to < and > to > |
| 12145 | (let ((start 0)) | 13133 | (let ((start 0)) |
| @@ -12152,6 +13140,14 @@ But it has the disadvantage, that Org-mode's HTML conversions cannot be used." | |||
| 12152 | (setq s (replace-match ">" t t s)))) | 13140 | (setq s (replace-match ">" t t s)))) |
| 12153 | s) | 13141 | s) |
| 12154 | 13142 | ||
| 13143 | (defun org-html-cleanup-toc-line (s) | ||
| 13144 | "Remove tags and time staps from lines going into the toc." | ||
| 13145 | (if (string-match " +:[a-zA-Z0-9_@:]+: *$" s) | ||
| 13146 | (setq s (replace-match "" t t s))) | ||
| 13147 | (while (string-match org-maybe-keyword-time-regexp s) | ||
| 13148 | (setq s (replace-match "" t t s))) | ||
| 13149 | s) | ||
| 13150 | |||
| 12155 | (defun org-html-expand (string) | 13151 | (defun org-html-expand (string) |
| 12156 | "Prepare STRING for HTML export. Applies all active conversions. | 13152 | "Prepare STRING for HTML export. Applies all active conversions. |
| 12157 | If there are links in the string, don't modify these." | 13153 | If there are links in the string, don't modify these." |
| @@ -12212,6 +13208,7 @@ stacked delimiters is N. Escaping delimiters is not possible." | |||
| 12212 | "\\(" (org-create-multibrace-regexp "(" ")" org-match-sexp-depth) "\\)" | 13208 | "\\(" (org-create-multibrace-regexp "(" ")" org-match-sexp-depth) "\\)" |
| 12213 | "\\|" | 13209 | "\\|" |
| 12214 | "\\(\\(?:\\*\\|[-+]?[^-+*!@#$%^_ \t\r\n,:\"?<>~;./{}=()]+\\)\\)\\)") | 13210 | "\\(\\(?:\\*\\|[-+]?[^-+*!@#$%^_ \t\r\n,:\"?<>~;./{}=()]+\\)\\)\\)") |
| 13211 | ;;;;;;;;;;;;;;;;;;;;;;;;;^ FIXME | ||
| 12215 | "The regular expression matching a sub- or superscript.") | 13212 | "The regular expression matching a sub- or superscript.") |
| 12216 | 13213 | ||
| 12217 | (defun org-export-html-convert-sub-super (string) | 13214 | (defun org-export-html-convert-sub-super (string) |
| @@ -12239,49 +13236,9 @@ stacked delimiters is N. Escaping delimiters is not possible." | |||
| 12239 | (setq string (replace-match "\\1<u>\\3</u>\\4" t nil string))) | 13236 | (setq string (replace-match "\\1<u>\\3</u>\\4" t nil string))) |
| 12240 | string) | 13237 | string) |
| 12241 | 13238 | ||
| 12242 | (defun org-parse-key-lines () | ||
| 12243 | "Find the special key lines with the information for exporters." | ||
| 12244 | (save-excursion | ||
| 12245 | (goto-char 0) | ||
| 12246 | (let ((re (org-make-options-regexp | ||
| 12247 | '("TITLE" "AUTHOR" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE"))) | ||
| 12248 | key) | ||
| 12249 | (while (re-search-forward re nil t) | ||
| 12250 | (setq key (match-string 1)) | ||
| 12251 | (cond ((string-equal key "TITLE") | ||
| 12252 | (setq title (match-string 2))) | ||
| 12253 | ((string-equal key "AUTHOR") | ||
| 12254 | (setq author (match-string 2))) | ||
| 12255 | ((string-equal key "EMAIL") | ||
| 12256 | (setq email (match-string 2))) | ||
| 12257 | ((string-equal key "LANGUAGE") | ||
| 12258 | (setq language (match-string 2))) | ||
| 12259 | ((string-equal key "TEXT") | ||
| 12260 | (setq text (concat text "\n" (match-string 2)))) | ||
| 12261 | ((string-equal key "OPTIONS") | ||
| 12262 | (setq options (match-string 2)))))))) | ||
| 12263 | |||
| 12264 | (defun org-parse-export-options (s) | ||
| 12265 | "Parse the export options line." | ||
| 12266 | (let ((op '(("H" . org-export-headline-levels) | ||
| 12267 | ("num" . org-export-with-section-numbers) | ||
| 12268 | ("toc" . org-export-with-toc) | ||
| 12269 | ("\\n" . org-export-preserve-breaks) | ||
| 12270 | ("@" . org-export-html-expand) | ||
| 12271 | (":" . org-export-with-fixed-width) | ||
| 12272 | ("|" . org-export-with-tables) | ||
| 12273 | ("^" . org-export-with-sub-superscripts) | ||
| 12274 | ("*" . org-export-with-emphasize) | ||
| 12275 | ("TeX" . org-export-with-TeX-macros))) | ||
| 12276 | o) | ||
| 12277 | (while (setq o (pop op)) | ||
| 12278 | (if (string-match (concat (regexp-quote (car o)) ":\\([^ \t\n\r;,.]*\\)") | ||
| 12279 | s) | ||
| 12280 | (set (make-local-variable (cdr o)) | ||
| 12281 | (car (read-from-string (match-string 1 s)))))))) | ||
| 12282 | |||
| 12283 | (defun org-html-level-start (level title umax with-toc head-count) | 13239 | (defun org-html-level-start (level title umax with-toc head-count) |
| 12284 | "Insert a new level in HTML export." | 13240 | "Insert a new level in HTML export. |
| 13241 | When TITLE is nil, just close all open levels." | ||
| 12285 | (let ((l (1+ (max level umax)))) | 13242 | (let ((l (1+ (max level umax)))) |
| 12286 | (while (<= l org-level-max) | 13243 | (while (<= l org-level-max) |
| 12287 | (if (aref levels-open (1- l)) | 13244 | (if (aref levels-open (1- l)) |
| @@ -12289,19 +13246,35 @@ stacked delimiters is N. Escaping delimiters is not possible." | |||
| 12289 | (org-html-level-close l) | 13246 | (org-html-level-close l) |
| 12290 | (aset levels-open (1- l) nil))) | 13247 | (aset levels-open (1- l) nil))) |
| 12291 | (setq l (1+ l))) | 13248 | (setq l (1+ l))) |
| 12292 | (if (> level umax) | 13249 | (when title |
| 12293 | (progn | 13250 | ;; If title is nil, this means this function is called to close |
| 12294 | (if (aref levels-open (1- level)) | 13251 | ;; all levels, so the rest is done only if title is given |
| 12295 | (insert "<li>" title "<p>\n") | 13252 | (if (> level umax) |
| 12296 | (aset levels-open (1- level) t) | 13253 | (progn |
| 12297 | (insert "<ul><li>" title "<p>\n"))) | 13254 | (if (aref levels-open (1- level)) |
| 12298 | (if org-export-with-section-numbers | 13255 | (insert "<li>" title "<p>\n") |
| 12299 | (setq title (concat (org-section-number level) " " title))) | 13256 | (aset levels-open (1- level) t) |
| 12300 | (setq level (+ level 1)) | 13257 | (insert "<ul><li>" title "<p>\n"))) |
| 12301 | (if with-toc | 13258 | (if org-export-with-section-numbers |
| 12302 | (insert (format "\n<H%d><a name=\"sec-%d\">%s</a></H%d>\n" | 13259 | (setq title (concat (org-section-number level) " " title))) |
| 12303 | level head-count title level)) | 13260 | (setq level (+ level 1)) |
| 12304 | (insert (format "\n<H%d>%s</H%d>\n" level title level)))))) | 13261 | ;; FIXME: here we need to handle the tags, somehow. |
| 13262 | (when (string-match "\\(:[a-zA-Z0-9_@:]+:\\)[ \t]*$" title) | ||
| 13263 | (setq title (replace-match | ||
| 13264 | (if org-export-with-tags | ||
| 13265 | (save-match-data | ||
| 13266 | (concat | ||
| 13267 | " <span class=\"tag\">" | ||
| 13268 | (mapconcat 'identity (org-split-string | ||
| 13269 | (match-string 1 title) ":") | ||
| 13270 | " ") | ||
| 13271 | "</span>")) | ||
| 13272 | "") | ||
| 13273 | t t title))) | ||
| 13274 | (if with-toc | ||
| 13275 | (insert (format "\n<H%d><a name=\"sec-%d\">%s</a></H%d>\n" | ||
| 13276 | level head-count title level)) | ||
| 13277 | (insert (format "\n<H%d>%s</H%d>\n" level title level))))))) | ||
| 12305 | 13278 | ||
| 12306 | (defun org-html-level-close (&rest args) | 13279 | (defun org-html-level-close (&rest args) |
| 12307 | "Terminate one level in HTML export." | 13280 | "Terminate one level in HTML export." |
| @@ -12361,9 +13334,9 @@ file, but with extension `.ics'." | |||
| 12361 | (interactive) | 13334 | (interactive) |
| 12362 | (org-export-icalendar nil buffer-file-name)) | 13335 | (org-export-icalendar nil buffer-file-name)) |
| 12363 | 13336 | ||
| 12364 | (defun org-export-as-xml () | 13337 | (defun org-export-as-xml (arg) |
| 12365 | "Export current buffer as XOXO XML buffer." | 13338 | "Export current buffer as XOXO XML buffer." |
| 12366 | (interactive) | 13339 | (interactive "P") |
| 12367 | (cond ((eq org-export-xml-type 'xoxo) | 13340 | (cond ((eq org-export-xml-type 'xoxo) |
| 12368 | (org-export-as-xoxo (current-buffer))))) | 13341 | (org-export-as-xoxo (current-buffer))))) |
| 12369 | 13342 | ||
| @@ -12380,8 +13353,13 @@ The XOXO buffer is named *xoxo-<source buffer name>*" | |||
| 12380 | ;; Output everything as XOXO | 13353 | ;; Output everything as XOXO |
| 12381 | (with-current-buffer (get-buffer buffer) | 13354 | (with-current-buffer (get-buffer buffer) |
| 12382 | (goto-char (point-min)) ;; CD: beginning-of-buffer is not allowed. | 13355 | (goto-char (point-min)) ;; CD: beginning-of-buffer is not allowed. |
| 12383 | (let* ((filename (concat (file-name-sans-extension buffer-file-name) | 13356 | (let* ((opt-plist (org-combine-plists (org-default-export-plist) |
| 12384 | ".xml")) | 13357 | (org-infile-export-plist))) |
| 13358 | (filename (concat (file-name-as-directory | ||
| 13359 | (org-export-directory :xoxo opt-plist)) | ||
| 13360 | (file-name-sans-extension | ||
| 13361 | (file-name-nondirectory buffer-file-name)) | ||
| 13362 | ".html")) | ||
| 12385 | (out (find-file-noselect filename)) | 13363 | (out (find-file-noselect filename)) |
| 12386 | (last-level 1) | 13364 | (last-level 1) |
| 12387 | (hanging-li nil)) | 13365 | (hanging-li nil)) |
| @@ -12464,19 +13442,29 @@ The file is stored under the name `org-combined-agenda-icalendar-file'." | |||
| 12464 | If COMBINE is non-nil, combine all calendar entries into a single large | 13442 | If COMBINE is non-nil, combine all calendar entries into a single large |
| 12465 | file and store it under the name `org-combined-agenda-icalendar-file'." | 13443 | file and store it under the name `org-combined-agenda-icalendar-file'." |
| 12466 | (save-excursion | 13444 | (save-excursion |
| 12467 | (let* (file ical-file ical-buffer category started org-agenda-new-buffers) | 13445 | (let* ((dir (org-export-directory |
| 13446 | :ical (list :publishing-directory | ||
| 13447 | org-export-publishing-directory))) | ||
| 13448 | file ical-file ical-buffer category started org-agenda-new-buffers) | ||
| 13449 | |||
| 12468 | (when combine | 13450 | (when combine |
| 12469 | (setq ical-file org-combined-agenda-icalendar-file | 13451 | (setq ical-file |
| 13452 | (if (file-name-absolute-p org-combined-agenda-icalendar-file) | ||
| 13453 | org-combined-agenda-icalendar-file | ||
| 13454 | (expand-file-name org-combined-agenda-icalendar-file dir)) | ||
| 12470 | ical-buffer (org-get-agenda-file-buffer ical-file)) | 13455 | ical-buffer (org-get-agenda-file-buffer ical-file)) |
| 12471 | (set-buffer ical-buffer) (erase-buffer)) | 13456 | (set-buffer ical-buffer) (erase-buffer)) |
| 12472 | (while (setq file (pop files)) | 13457 | (while (setq file (pop files)) |
| 12473 | (catch 'nextfile | 13458 | (catch 'nextfile |
| 12474 | (org-check-agenda-file file) | 13459 | (org-check-agenda-file file) |
| 13460 | (set-buffer (org-get-agenda-file-buffer file)) | ||
| 12475 | (unless combine | 13461 | (unless combine |
| 12476 | (setq ical-file (concat (file-name-sans-extension file) ".ics")) | 13462 | (setq ical-file (concat (file-name-as-directory dir) |
| 13463 | (file-name-sans-extension | ||
| 13464 | (file-name-nondirectory buffer-file-name)) | ||
| 13465 | ".ics")) | ||
| 12477 | (setq ical-buffer (org-get-agenda-file-buffer ical-file)) | 13466 | (setq ical-buffer (org-get-agenda-file-buffer ical-file)) |
| 12478 | (set-buffer ical-buffer) (erase-buffer)) | 13467 | (with-current-buffer ical-buffer (erase-buffer))) |
| 12479 | (set-buffer (org-get-agenda-file-buffer file)) | ||
| 12480 | (setq category (or org-category | 13468 | (setq category (or org-category |
| 12481 | (file-name-sans-extension | 13469 | (file-name-sans-extension |
| 12482 | (file-name-nondirectory buffer-file-name)))) | 13470 | (file-name-nondirectory buffer-file-name)))) |
| @@ -12611,6 +13599,7 @@ a time), or the day by one (if it does not contain a time)." | |||
| 12611 | 13599 | ||
| 12612 | ;; Make `C-c C-x' a prefix key | 13600 | ;; Make `C-c C-x' a prefix key |
| 12613 | (define-key org-mode-map "\C-c\C-x" (make-sparse-keymap)) | 13601 | (define-key org-mode-map "\C-c\C-x" (make-sparse-keymap)) |
| 13602 | (define-key org-mode-map "\C-c\C-e" (make-sparse-keymap)) | ||
| 12614 | 13603 | ||
| 12615 | ;; TAB key with modifiers | 13604 | ;; TAB key with modifiers |
| 12616 | (define-key org-mode-map "\C-i" 'org-cycle) | 13605 | (define-key org-mode-map "\C-i" 'org-cycle) |
| @@ -12708,8 +13697,8 @@ a time), or the day by one (if it does not contain a time)." | |||
| 12708 | (define-key org-mode-map "\C-c\C-q" 'org-table-wrap-region) | 13697 | (define-key org-mode-map "\C-c\C-q" 'org-table-wrap-region) |
| 12709 | (define-key org-mode-map "\C-c\C-xa" 'org-export-as-ascii) | 13698 | (define-key org-mode-map "\C-c\C-xa" 'org-export-as-ascii) |
| 12710 | (define-key org-mode-map "\C-c\C-x\C-a" 'org-export-as-ascii) | 13699 | (define-key org-mode-map "\C-c\C-x\C-a" 'org-export-as-ascii) |
| 12711 | (define-key org-mode-map "\C-c\C-xv" 'org-export-copy-visible) | 13700 | (define-key org-mode-map "\C-c\C-xv" 'org-export-visible) |
| 12712 | (define-key org-mode-map "\C-c\C-x\C-v" 'org-export-copy-visible) | 13701 | (define-key org-mode-map "\C-c\C-x\C-v" 'org-export-visible) |
| 12713 | ;; OPML support is only an option for the future | 13702 | ;; OPML support is only an option for the future |
| 12714 | ;(define-key org-mode-map "\C-c\C-xo" 'org-export-as-opml) | 13703 | ;(define-key org-mode-map "\C-c\C-xo" 'org-export-as-opml) |
| 12715 | ;(define-key org-mode-map "\C-c\C-x\C-o" 'org-export-as-opml) | 13704 | ;(define-key org-mode-map "\C-c\C-x\C-o" 'org-export-as-opml) |
| @@ -12730,6 +13719,18 @@ a time), or the day by one (if it does not contain a time)." | |||
| 12730 | (define-key org-mode-map "\C-c\C-x\M-w" 'org-copy-special) | 13719 | (define-key org-mode-map "\C-c\C-x\M-w" 'org-copy-special) |
| 12731 | (define-key org-mode-map "\C-c\C-x\C-y" 'org-paste-special) | 13720 | (define-key org-mode-map "\C-c\C-x\C-y" 'org-paste-special) |
| 12732 | 13721 | ||
| 13722 | (define-key org-mode-map "\C-c\C-ef" 'org-publish-current-file) | ||
| 13723 | (define-key org-mode-map "\C-c\C-ep" 'org-publish-current-project) | ||
| 13724 | (define-key org-mode-map "\C-c\C-ec" 'org-publish) | ||
| 13725 | (define-key org-mode-map "\C-c\C-ea" 'org-publish-all) | ||
| 13726 | (define-key org-mode-map "\C-c\C-e\C-f" 'org-publish-current-file) | ||
| 13727 | (define-key org-mode-map "\C-c\C-e\C-p" 'org-publish-current-project) | ||
| 13728 | (define-key org-mode-map "\C-c\C-e\C-c" 'org-publish) | ||
| 13729 | (define-key org-mode-map "\C-c\C-e\C-a" 'org-publish-all) | ||
| 13730 | |||
| 13731 | (when (featurep 'xemacs) | ||
| 13732 | (define-key org-mode-map 'button3 'popup-mode-menu)) | ||
| 13733 | |||
| 12733 | (defsubst org-table-p () (org-at-table-p)) | 13734 | (defsubst org-table-p () (org-at-table-p)) |
| 12734 | 13735 | ||
| 12735 | (defun org-self-insert-command (N) | 13736 | (defun org-self-insert-command (N) |
| @@ -12803,7 +13804,8 @@ because, in this case the deletion might narrow the column." | |||
| 12803 | (goto-char pos) | 13804 | (goto-char pos) |
| 12804 | ;; noalign: if there were two spaces at the end, this field | 13805 | ;; noalign: if there were two spaces at the end, this field |
| 12805 | ;; does not determine the width of the column. | 13806 | ;; does not determine the width of the column. |
| 12806 | (if noalign (setq org-table-may-need-update c)))) | 13807 | (if noalign (setq org-table-may-need-update c))) |
| 13808 | (delete-char N)) | ||
| 12807 | (delete-char N))) | 13809 | (delete-char N))) |
| 12808 | 13810 | ||
| 12809 | ;; How to do this: Measure non-white length of current string | 13811 | ;; How to do this: Measure non-white length of current string |
| @@ -12834,12 +13836,13 @@ COMMANDS is a list of alternating OLDDEF NEWDEF command names." | |||
| 12834 | 13836 | ||
| 12835 | (defun org-shifttab () | 13837 | (defun org-shifttab () |
| 12836 | "Global visibility cycling or move to previous table field. | 13838 | "Global visibility cycling or move to previous table field. |
| 12837 | Calls `(org-cycle t)' or `org-table-previous-field', depending on context. | 13839 | Calls `org-cycle' with argument t, or `org-table-previous-field', depending |
| 13840 | on context. | ||
| 12838 | See the individual commands for more information." | 13841 | See the individual commands for more information." |
| 12839 | (interactive) | 13842 | (interactive) |
| 12840 | (cond | 13843 | (cond |
| 12841 | ((org-at-table-p) (org-table-previous-field)) | 13844 | ((org-at-table-p) (call-interactively 'org-table-previous-field)) |
| 12842 | (t (org-cycle '(4))))) | 13845 | (t (call-interactively 'org-global-cycle)))) |
| 12843 | 13846 | ||
| 12844 | (defun org-shiftmetaleft () | 13847 | (defun org-shiftmetaleft () |
| 12845 | "Promote subtree or delete table column. | 13848 | "Promote subtree or delete table column. |
| @@ -12847,8 +13850,8 @@ Calls `org-promote-subtree' or `org-table-delete-column', depending on context. | |||
| 12847 | See the individual commands for more information." | 13850 | See the individual commands for more information." |
| 12848 | (interactive) | 13851 | (interactive) |
| 12849 | (cond | 13852 | (cond |
| 12850 | ((org-at-table-p) (org-table-delete-column)) | 13853 | ((org-at-table-p) (call-interactively 'org-table-delete-column)) |
| 12851 | ((org-on-heading-p) (org-promote-subtree)) | 13854 | ((org-on-heading-p) (call-interactively 'org-promote-subtree)) |
| 12852 | ((org-at-item-p) (call-interactively 'org-outdent-item)) | 13855 | ((org-at-item-p) (call-interactively 'org-outdent-item)) |
| 12853 | (t (org-shiftcursor-error)))) | 13856 | (t (org-shiftcursor-error)))) |
| 12854 | 13857 | ||
| @@ -12858,8 +13861,8 @@ Calls `org-demote-subtree' or `org-table-insert-column', depending on context. | |||
| 12858 | See the individual commands for more information." | 13861 | See the individual commands for more information." |
| 12859 | (interactive) | 13862 | (interactive) |
| 12860 | (cond | 13863 | (cond |
| 12861 | ((org-at-table-p) (org-table-insert-column)) | 13864 | ((org-at-table-p) (call-interactively 'org-table-insert-column)) |
| 12862 | ((org-on-heading-p) (org-demote-subtree)) | 13865 | ((org-on-heading-p) (call-interactively 'org-demote-subtree)) |
| 12863 | ((org-at-item-p) (call-interactively 'org-indent-item)) | 13866 | ((org-at-item-p) (call-interactively 'org-indent-item)) |
| 12864 | (t (org-shiftcursor-error)))) | 13867 | (t (org-shiftcursor-error)))) |
| 12865 | 13868 | ||
| @@ -12870,9 +13873,9 @@ Calls `org-move-subtree-up' or `org-table-kill-row' or | |||
| 12870 | for more information." | 13873 | for more information." |
| 12871 | (interactive "P") | 13874 | (interactive "P") |
| 12872 | (cond | 13875 | (cond |
| 12873 | ((org-at-table-p) (org-table-kill-row)) | 13876 | ((org-at-table-p) (call-interactively 'org-table-kill-row)) |
| 12874 | ((org-on-heading-p) (org-move-subtree-up arg)) | 13877 | ((org-on-heading-p) (call-interactively 'org-move-subtree-up)) |
| 12875 | ((org-at-item-p) (org-move-item-up arg)) | 13878 | ((org-at-item-p) (call-interactively 'org-move-item-up)) |
| 12876 | (t (org-shiftcursor-error)))) | 13879 | (t (org-shiftcursor-error)))) |
| 12877 | (defun org-shiftmetadown (&optional arg) | 13880 | (defun org-shiftmetadown (&optional arg) |
| 12878 | "Move subtree down or insert table row. | 13881 | "Move subtree down or insert table row. |
| @@ -12881,9 +13884,9 @@ Calls `org-move-subtree-down' or `org-table-insert-row' or | |||
| 12881 | commands for more information." | 13884 | commands for more information." |
| 12882 | (interactive "P") | 13885 | (interactive "P") |
| 12883 | (cond | 13886 | (cond |
| 12884 | ((org-at-table-p) (org-table-insert-row arg)) | 13887 | ((org-at-table-p) (call-interactively 'org-table-insert-row)) |
| 12885 | ((org-on-heading-p) (org-move-subtree-down arg)) | 13888 | ((org-on-heading-p) (call-interactively 'org-move-subtree-down)) |
| 12886 | ((org-at-item-p) (org-move-item-down arg)) | 13889 | ((org-at-item-p) (call-interactively 'org-move-item-down)) |
| 12887 | (t (org-shiftcursor-error)))) | 13890 | (t (org-shiftcursor-error)))) |
| 12888 | 13891 | ||
| 12889 | (defun org-metaleft (&optional arg) | 13892 | (defun org-metaleft (&optional arg) |
| @@ -12893,9 +13896,10 @@ With no specific context, calls the Emacs default `backward-word'. | |||
| 12893 | See the individual commands for more information." | 13896 | See the individual commands for more information." |
| 12894 | (interactive "P") | 13897 | (interactive "P") |
| 12895 | (cond | 13898 | (cond |
| 12896 | ((org-at-table-p) (org-table-move-column 'left)) | 13899 | ((org-at-table-p) (org-call-with-arg 'org-table-move-column 'left)) |
| 12897 | ((or (org-on-heading-p) (org-region-active-p)) (org-do-promote)) | 13900 | ((or (org-on-heading-p) (org-region-active-p)) |
| 12898 | (t (backward-word (prefix-numeric-value arg))))) | 13901 | (call-interactively 'org-do-promote)) |
| 13902 | (t (call-interactively 'backward-word)))) | ||
| 12899 | 13903 | ||
| 12900 | (defun org-metaright (&optional arg) | 13904 | (defun org-metaright (&optional arg) |
| 12901 | "Demote subtree or move table column to right. | 13905 | "Demote subtree or move table column to right. |
| @@ -12904,9 +13908,10 @@ With no specific context, calls the Emacs default `forward-word'. | |||
| 12904 | See the individual commands for more information." | 13908 | See the individual commands for more information." |
| 12905 | (interactive "P") | 13909 | (interactive "P") |
| 12906 | (cond | 13910 | (cond |
| 12907 | ((org-at-table-p) (org-table-move-column nil)) | 13911 | ((org-at-table-p) (call-interactively 'org-table-move-column)) |
| 12908 | ((or (org-on-heading-p) (org-region-active-p)) (org-do-demote)) | 13912 | ((or (org-on-heading-p) (org-region-active-p)) |
| 12909 | (t (forward-word (prefix-numeric-value arg))))) | 13913 | (call-interactively 'org-do-demote)) |
| 13914 | (t (call-interactively 'forward-word)))) | ||
| 12910 | 13915 | ||
| 12911 | (defun org-metaup (&optional arg) | 13916 | (defun org-metaup (&optional arg) |
| 12912 | "Move subtree up or move table row up. | 13917 | "Move subtree up or move table row up. |
| @@ -12915,9 +13920,9 @@ Calls `org-move-subtree-up' or `org-table-move-row' or | |||
| 12915 | for more information." | 13920 | for more information." |
| 12916 | (interactive "P") | 13921 | (interactive "P") |
| 12917 | (cond | 13922 | (cond |
| 12918 | ((org-at-table-p) (org-table-move-row 'up)) | 13923 | ((org-at-table-p) (org-call-with-arg 'org-table-move-row 'up)) |
| 12919 | ((org-on-heading-p) (org-move-subtree-up arg)) | 13924 | ((org-on-heading-p) (call-interactively 'org-move-subtree-up)) |
| 12920 | ((org-at-item-p) (org-move-item-up arg)) | 13925 | ((org-at-item-p) (call-interactively 'org-move-item-up)) |
| 12921 | (t (org-shiftcursor-error)))) | 13926 | (t (org-shiftcursor-error)))) |
| 12922 | 13927 | ||
| 12923 | (defun org-metadown (&optional arg) | 13928 | (defun org-metadown (&optional arg) |
| @@ -12927,43 +13932,46 @@ Calls `org-move-subtree-down' or `org-table-move-row' or | |||
| 12927 | commands for more information." | 13932 | commands for more information." |
| 12928 | (interactive "P") | 13933 | (interactive "P") |
| 12929 | (cond | 13934 | (cond |
| 12930 | ((org-at-table-p) (org-table-move-row nil)) | 13935 | ((org-at-table-p) (call-interactively 'org-table-move-row)) |
| 12931 | ((org-on-heading-p) (org-move-subtree-down arg)) | 13936 | ((org-on-heading-p) (call-interactively 'org-move-subtree-down)) |
| 12932 | ((org-at-item-p) (org-move-item-down arg)) | 13937 | ((org-at-item-p) (call-interactively 'org-move-item-down)) |
| 12933 | (t (org-shiftcursor-error)))) | 13938 | (t (org-shiftcursor-error)))) |
| 12934 | 13939 | ||
| 12935 | (defun org-shiftup (&optional arg) | 13940 | (defun org-shiftup (&optional arg) |
| 12936 | "Increase item in timestamp or increase priority of current item. | 13941 | "Increase item in timestamp or increase priority of current headline. |
| 12937 | Calls `org-timestamp-up' or `org-priority-up', depending on context. | 13942 | Calls `org-timestamp-up' or `org-priority-up', depending on context. |
| 12938 | See the individual commands for more information." | 13943 | See the individual commands for more information." |
| 12939 | (interactive "P") | 13944 | (interactive "P") |
| 12940 | (cond | 13945 | (cond |
| 12941 | ((org-at-timestamp-p) (org-timestamp-up arg)) | 13946 | ((org-at-timestamp-p) (call-interactively 'org-timestamp-up)) |
| 12942 | (t (org-priority-up)))) | 13947 | ((org-on-heading-p) (call-interactively 'org-priority-up)) |
| 13948 | ((org-at-item-p) (call-interactively 'org-previous-item)) | ||
| 13949 | (t (call-interactively 'org-beginning-of-item) (beginning-of-line 1)))) | ||
| 12943 | 13950 | ||
| 12944 | (defun org-shiftdown (&optional arg) | 13951 | (defun org-shiftdown (&optional arg) |
| 12945 | "Decrease item in timestamp or decrease priority of current item. | 13952 | "Decrease item in timestamp or decrease priority of current headline. |
| 12946 | Calls `org-timestamp-down' or `org-priority-down', depending on context. | 13953 | Calls `org-timestamp-down' or `org-priority-down', depending on context. |
| 12947 | See the individual commands for more information." | 13954 | See the individual commands for more information." |
| 12948 | (interactive "P") | 13955 | (interactive "P") |
| 12949 | (cond | 13956 | (cond |
| 12950 | ((org-at-timestamp-p) (org-timestamp-down arg)) | 13957 | ((org-at-timestamp-p) (call-interactively 'org-timestamp-down)) |
| 12951 | (t (org-priority-down)))) | 13958 | ((org-on-heading-p) (call-interactively 'org-priority-down)) |
| 13959 | (t (call-interactively 'org-next-item)))) | ||
| 12952 | 13960 | ||
| 12953 | (defun org-shiftright () | 13961 | (defun org-shiftright () |
| 12954 | "Next TODO keyword or timestamp one day later, depending on context." | 13962 | "Next TODO keyword or timestamp one day later, depending on context." |
| 12955 | (interactive) | 13963 | (interactive) |
| 12956 | (cond | 13964 | (cond |
| 12957 | ((org-at-timestamp-p) (org-timestamp-up-day)) | 13965 | ((org-at-timestamp-p) (call-interactively 'org-timestamp-up-day)) |
| 12958 | ((org-on-heading-p) (org-todo 'right)) | 13966 | ((org-on-heading-p) (org-call-with-arg 'org-todo 'right)) |
| 12959 | (t (org-shiftcursor-error)))) | 13967 | (t (org-shiftcursor-error)))) |
| 12960 | 13968 | ||
| 12961 | (defun org-shiftleft () | 13969 | (defun org-shiftleft () |
| 12962 | "Previous TODO keyword or timestamp one day earlier, depending on context." | 13970 | "Previous TODO keyword or timestamp one day earlier, depending on context." |
| 12963 | (interactive) | 13971 | (interactive) |
| 12964 | (cond | 13972 | (cond |
| 12965 | ((org-at-timestamp-p) (org-timestamp-down-day)) | 13973 | ((org-at-timestamp-p) (call-interactively 'org-timestamp-down-day)) |
| 12966 | ((org-on-heading-p) (org-todo 'left)) | 13974 | ((org-on-heading-p) (org-call-with-arg 'org-todo 'left)) |
| 12967 | (t (org-shiftcursor-error)))) | 13975 | (t (org-shiftcursor-error)))) |
| 12968 | 13976 | ||
| 12969 | (defun org-copy-special () | 13977 | (defun org-copy-special () |
| @@ -13028,21 +14036,23 @@ This command does many different things, depending on context: | |||
| 13028 | ((and (local-variable-p 'org-finish-function (current-buffer)) | 14036 | ((and (local-variable-p 'org-finish-function (current-buffer)) |
| 13029 | (fboundp org-finish-function)) | 14037 | (fboundp org-finish-function)) |
| 13030 | (funcall org-finish-function)) | 14038 | (funcall org-finish-function)) |
| 13031 | ((org-on-target-p) (org-update-radio-target-regexp)) | 14039 | ((org-on-target-p) (call-interactively 'org-update-radio-target-regexp)) |
| 13032 | ((org-on-heading-p) (org-set-tags arg)) | 14040 | ((org-on-heading-p) (call-interactively 'org-set-tags)) |
| 13033 | ((org-at-table.el-p) | 14041 | ((org-at-table.el-p) |
| 13034 | (require 'table) | 14042 | (require 'table) |
| 13035 | (beginning-of-line 1) | 14043 | (beginning-of-line 1) |
| 13036 | (re-search-forward "|" (save-excursion (end-of-line 2) (point))) | 14044 | (re-search-forward "|" (save-excursion (end-of-line 2) (point))) |
| 13037 | (table-recognize-table)) | 14045 | (call-interactively 'table-recognize-table)) |
| 13038 | ((org-at-table-p) | 14046 | ((org-at-table-p) |
| 13039 | (org-table-maybe-eval-formula) | 14047 | (org-table-maybe-eval-formula) |
| 13040 | (if arg | 14048 | (if arg |
| 13041 | (org-table-recalculate t) | 14049 | (call-interactively 'org-table-recalculate) |
| 13042 | (org-table-maybe-recalculate-line)) | 14050 | (org-table-maybe-recalculate-line)) |
| 13043 | (org-table-align)) | 14051 | (call-interactively 'org-table-align)) |
| 14052 | ((org-at-item-checkbox-p) | ||
| 14053 | (call-interactively 'org-toggle-checkbox)) | ||
| 13044 | ((org-at-item-p) | 14054 | ((org-at-item-p) |
| 13045 | (org-renumber-ordered-list (prefix-numeric-value arg))) | 14055 | (call-interactively 'org-renumber-ordered-list)) |
| 13046 | ((save-excursion (beginning-of-line 1) (looking-at "#\\+\\([A-Z]+\\)")) | 14056 | ((save-excursion (beginning-of-line 1) (looking-at "#\\+\\([A-Z]+\\)")) |
| 13047 | (cond | 14057 | (cond |
| 13048 | ((equal (match-string 1) "TBLFM") | 14058 | ((equal (match-string 1) "TBLFM") |
| @@ -13050,9 +14060,10 @@ This command does many different things, depending on context: | |||
| 13050 | (save-excursion | 14060 | (save-excursion |
| 13051 | (beginning-of-line 1) | 14061 | (beginning-of-line 1) |
| 13052 | (skip-chars-backward " \r\n\t") | 14062 | (skip-chars-backward " \r\n\t") |
| 13053 | (if (org-at-table-p) (org-table-recalculate t)))) | 14063 | (if (org-at-table-p) |
| 14064 | (org-call-with-arg 'org-table-recalculate t)))) | ||
| 13054 | (t | 14065 | (t |
| 13055 | (org-mode-restart)))) | 14066 | (call-interactively 'org-mode-restart)))) |
| 13056 | (t (error "C-c C-c can do nothing useful at this location."))))) | 14067 | (t (error "C-c C-c can do nothing useful at this location."))))) |
| 13057 | 14068 | ||
| 13058 | (defun org-mode-restart () | 14069 | (defun org-mode-restart () |
| @@ -13070,7 +14081,7 @@ See the individual commands for more information." | |||
| 13070 | (cond | 14081 | (cond |
| 13071 | ((org-at-table-p) | 14082 | ((org-at-table-p) |
| 13072 | (org-table-justify-field-maybe) | 14083 | (org-table-justify-field-maybe) |
| 13073 | (org-table-next-row)) | 14084 | (call-interactively 'org-table-next-row)) |
| 13074 | (t (newline)))) | 14085 | (t (newline)))) |
| 13075 | 14086 | ||
| 13076 | (defun org-meta-return (&optional arg) | 14087 | (defun org-meta-return (&optional arg) |
| @@ -13080,8 +14091,8 @@ See the individual commands for more information." | |||
| 13080 | (interactive "P") | 14091 | (interactive "P") |
| 13081 | (cond | 14092 | (cond |
| 13082 | ((org-at-table-p) | 14093 | ((org-at-table-p) |
| 13083 | (org-table-wrap-region arg)) | 14094 | (call-interactively 'org-table-wrap-region)) |
| 13084 | (t (org-insert-heading arg)))) | 14095 | (t (call-interactively 'org-insert-heading)))) |
| 13085 | 14096 | ||
| 13086 | ;;; Menu entries | 14097 | ;;; Menu entries |
| 13087 | 14098 | ||
| @@ -13226,10 +14237,10 @@ See the individual commands for more information." | |||
| 13226 | "--" | 14237 | "--" |
| 13227 | ("Export" | 14238 | ("Export" |
| 13228 | ["ASCII" org-export-as-ascii t] | 14239 | ["ASCII" org-export-as-ascii t] |
| 13229 | ["Extract Visible Text" org-export-copy-visible t] | 14240 | ["Export visible part..." org-export-visible t] |
| 13230 | ["HTML" org-export-as-html t] | 14241 | ["HTML" org-export-as-html t] |
| 13231 | ["HTML and Open" org-export-as-html-and-open t] | 14242 | ["HTML and Open" org-export-as-html-and-open t] |
| 13232 | ["XML (XOXO)" org-export-as-xml t] | 14243 | ["XOXO" org-export-as-xml t] |
| 13233 | "--" | 14244 | "--" |
| 13234 | ["iCalendar this file" org-export-icalendar-this-file t] | 14245 | ["iCalendar this file" org-export-icalendar-this-file t] |
| 13235 | ["iCalendar all agenda files" org-export-icalendar-all-agenda-files | 14246 | ["iCalendar all agenda files" org-export-icalendar-all-agenda-files |
| @@ -13238,6 +14249,11 @@ See the individual commands for more information." | |||
| 13238 | "--" | 14249 | "--" |
| 13239 | ["Option Template" org-insert-export-options-template t] | 14250 | ["Option Template" org-insert-export-options-template t] |
| 13240 | ["Toggle Fixed Width" org-toggle-fixed-width-section t]) | 14251 | ["Toggle Fixed Width" org-toggle-fixed-width-section t]) |
| 14252 | ("Publish" | ||
| 14253 | ["Current File" org-publish-current-file t] | ||
| 14254 | ["Current Project" org-publish-current-project t] | ||
| 14255 | ["Project..." org-publish t] | ||
| 14256 | ["All Projects" org-publish-all t]) | ||
| 13241 | "--" | 14257 | "--" |
| 13242 | ("Documentation" | 14258 | ("Documentation" |
| 13243 | ["Show Version" org-version t] | 14259 | ["Show Version" org-version t] |
| @@ -13451,7 +14467,7 @@ that can be added." | |||
| 13451 | ;; The following functions capture almost the entire compatibility code | 14467 | ;; The following functions capture almost the entire compatibility code |
| 13452 | ;; between the different versions of outline-mode. The only other | 14468 | ;; between the different versions of outline-mode. The only other |
| 13453 | ;; places where this is important are the font-lock-keywords, and in | 14469 | ;; places where this is important are the font-lock-keywords, and in |
| 13454 | ;; `org-export-copy-visible'. Search for `org-noutline-p' to find them. | 14470 | ;; `org-export-visible'. Search for `org-noutline-p' to find them. |
| 13455 | 14471 | ||
| 13456 | ;; C-a should go to the beginning of a *visible* line, also in the | 14472 | ;; C-a should go to the beginning of a *visible* line, also in the |
| 13457 | ;; new outline.el. I guess this should be patched into Emacs? | 14473 | ;; new outline.el. I guess this should be patched into Emacs? |
| @@ -13503,15 +14519,15 @@ to a visible line beginning. This makes the function of C-a more intuitive." | |||
| 13503 | Only visible heading lines are considered, unless INVISIBLE-OK is non-nil." | 14519 | Only visible heading lines are considered, unless INVISIBLE-OK is non-nil." |
| 13504 | (if org-noutline-p | 14520 | (if org-noutline-p |
| 13505 | (outline-back-to-heading invisible-ok) | 14521 | (outline-back-to-heading invisible-ok) |
| 13506 | (if (and (memq (char-before) '(?\n ?\r)) | 14522 | (if (and (or (bobp) (memq (char-before) '(?\n ?\r))) |
| 13507 | (looking-at outline-regexp)) | 14523 | (looking-at outline-regexp)) |
| 13508 | t | 14524 | t |
| 13509 | (if (re-search-backward (concat (if invisible-ok "\\([\r\n]\\|^\\)" "^") | 14525 | (if (re-search-backward (concat (if invisible-ok "\\([\r\n]\\|^\\)" "^") |
| 13510 | outline-regexp) | 14526 | outline-regexp) |
| 13511 | nil t) | 14527 | nil t) |
| 13512 | (if invisible-ok | 14528 | (if invisible-ok |
| 13513 | (progn (goto-char (match-end 1)) | 14529 | (progn (goto-char (or (match-end 1) (match-beginning 0))) |
| 13514 | (looking-at outline-regexp))) | 14530 | (looking-at outline-regexp))) |
| 13515 | (error "Before first heading"))))) | 14531 | (error "Before first heading"))))) |
| 13516 | 14532 | ||
| 13517 | (defun org-on-heading-p (&optional invisible-ok) | 14533 | (defun org-on-heading-p (&optional invisible-ok) |
| @@ -13585,10 +14601,9 @@ When ENTRY is non-nil, show the entire entry." | |||
| 13585 | (if entry | 14601 | (if entry |
| 13586 | (progn | 14602 | (progn |
| 13587 | (org-show-entry) | 14603 | (org-show-entry) |
| 13588 | (save-excursion ;; FIXME: Is this the fix for points in the -| | 14604 | (save-excursion |
| 13589 | ;; middle of text? | | 14605 | (and (outline-next-heading) |
| 13590 | (and (outline-next-heading) ;; | | 14606 | (org-flag-heading nil)))) |
| 13591 | (org-flag-heading nil)))) ; show the next heading _| | ||
| 13592 | (outline-flag-region (max 1 (1- (point))) | 14607 | (outline-flag-region (max 1 (1- (point))) |
| 13593 | (save-excursion (outline-end-of-heading) (point)) | 14608 | (save-excursion (outline-end-of-heading) (point)) |
| 13594 | (if org-noutline-p | 14609 | (if org-noutline-p |
| @@ -13630,7 +14645,7 @@ Show the heading too, if it is currently invisible." | |||
| 13630 | (save-excursion | 14645 | (save-excursion |
| 13631 | (org-back-to-heading t) | 14646 | (org-back-to-heading t) |
| 13632 | (outline-flag-region | 14647 | (outline-flag-region |
| 13633 | (1- (point)) | 14648 | (max 1 (1- (point))) |
| 13634 | (save-excursion | 14649 | (save-excursion |
| 13635 | (re-search-forward (concat "[\r\n]\\(" outline-regexp "\\)") nil 'move) | 14650 | (re-search-forward (concat "[\r\n]\\(" outline-regexp "\\)") nil 'move) |
| 13636 | (or (match-beginning 1) (point-max))) | 14651 | (or (match-beginning 1) (point-max))) |
| @@ -13669,6 +14684,6 @@ Show the heading too, if it is currently invisible." | |||
| 13669 | 14684 | ||
| 13670 | (run-hooks 'org-load-hook) | 14685 | (run-hooks 'org-load-hook) |
| 13671 | 14686 | ||
| 14687 | |||
| 13672 | ;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd | 14688 | ;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd |
| 13673 | ;;; org.el ends here | 14689 | ;;; org.el ends here |
| 13674 | |||