diff options
| author | Carsten Dominik | 2005-04-29 08:40:22 +0000 |
|---|---|---|
| committer | Carsten Dominik | 2005-04-29 08:40:22 +0000 |
| commit | 634a7d0b4a8c44b6c8559a7e58ec213cd2842a2a (patch) | |
| tree | 55cd93ef868c8c89d89301c31eb650742b5021e6 /lisp | |
| parent | 56c91423bf14d084409d8aa9c20519d485a12852 (diff) | |
| download | emacs-634a7d0b4a8c44b6c8559a7e58ec213cd2842a2a.tar.gz emacs-634a7d0b4a8c44b6c8559a7e58ec213cd2842a2a.zip | |
Many small changes to keep the byte compiler happy. Furthermore:
(org-prefix-format-compiled): New variable.
(org-compile-prefix-format): New function.
(org-timeline, org-agenda, org-diary): Call
`org-compile-prefix-format'.
(org-agenda-prefix-format,org-timeline-prefix-format): New
options.
(org-agenda-get-scheduled): Check if file is openned in
`org-mode'.
(org-get-entries-from-diary): Use `org-get-time-of-day', for
consistency with entries from `org-mode' files.
(org-get-time-of-day): Fixed bug with partial matches early in a
line.
(org-non-link-chars): New constant.
(org-link-regexp): Respect `org-non-link-chars'.
(org-agenda-day-view): Command removed.
(org-agenda-toggle-week-view): Renamed from
`org-agenda-week-view'.
(org-follow-bbdb-link, org-store-link): Search also company field.
(org-highlight-overlay): New variable.
(org-highlight, org-unhighlight): New functions.
(org-agenda-mode): Added pre-command-hook to remove highlight.
(org-evaluate-time-range): Behavior depend upon time stamp format:
Does it contain a time or not?
(org-show-subtree, org-show-entry): New functions.
(org-agenda-cleanup-fancy-diary): Remove empty lines.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/textmodes/org.el | 789 |
1 files changed, 463 insertions, 326 deletions
diff --git a/lisp/textmodes/org.el b/lisp/textmodes/org.el index c162160397e..2c0d1bea77c 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 | 6 | ;; Keywords: outlines, hypermedia, calendar |
| 7 | ;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/ | 7 | ;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/ |
| 8 | ;; Version: 3.06 | 8 | ;; Version: 3.08 |
| 9 | ;; | 9 | ;; |
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | ;; | 11 | ;; |
| @@ -79,6 +79,16 @@ | |||
| 79 | ;; | 79 | ;; |
| 80 | ;; Changes: | 80 | ;; Changes: |
| 81 | ;; ------- | 81 | ;; ------- |
| 82 | ;; Version 3.08 | ||
| 83 | ;; - "|" no longer allowed as part of a link, to allow links in tables. | ||
| 84 | ;; - The prefix of items in the agenda buffer can be configured. | ||
| 85 | ;; - Cleanup. | ||
| 86 | ;; | ||
| 87 | ;; Version 3.07 | ||
| 88 | ;; - Some folding incinsistencies removed. | ||
| 89 | ;; - BBDB links to company-only entries. | ||
| 90 | ;; - Bug fixes and global cleanup. | ||
| 91 | ;; | ||
| 82 | ;; Version 3.06 | 92 | ;; Version 3.06 |
| 83 | ;; - M-S-RET inserts a new TODO heading. | 93 | ;; - M-S-RET inserts a new TODO heading. |
| 84 | ;; - New startup option `content'. | 94 | ;; - New startup option `content'. |
| @@ -131,14 +141,14 @@ | |||
| 131 | 141 | ||
| 132 | ;;; Code: | 142 | ;;; Code: |
| 133 | 143 | ||
| 134 | (eval-when-compile (require 'cl)) | 144 | (eval-when-compile (require 'cl) (require 'calendar)) |
| 135 | (require 'outline) | 145 | (require 'outline) |
| 136 | (require 'time-date) | 146 | (require 'time-date) |
| 137 | (require 'easymenu) | 147 | (require 'easymenu) |
| 138 | 148 | ||
| 139 | ;;; Customization variables | 149 | ;;; Customization variables |
| 140 | 150 | ||
| 141 | (defvar org-version "3.06" | 151 | (defvar org-version "3.08" |
| 142 | "The version number of the file org.el.") | 152 | "The version number of the file org.el.") |
| 143 | (defun org-version () | 153 | (defun org-version () |
| 144 | (interactive) | 154 | (interactive) |
| @@ -194,8 +204,7 @@ This can also be configured on a per-file basis by adding one of | |||
| 194 | the following lines anywhere in the buffer: | 204 | the following lines anywhere in the buffer: |
| 195 | 205 | ||
| 196 | #+STARTUP: dlcheck | 206 | #+STARTUP: dlcheck |
| 197 | #+STARTUP: nodlcheck | 207 | #+STARTUP: nodlcheck" |
| 198 | " | ||
| 199 | :group 'org-startup | 208 | :group 'org-startup |
| 200 | :type 'boolean) | 209 | :type 'boolean) |
| 201 | 210 | ||
| @@ -215,8 +224,8 @@ has been set." | |||
| 215 | :group 'org) | 224 | :group 'org) |
| 216 | 225 | ||
| 217 | (defcustom org-todo-keywords '("TODO" "DONE") | 226 | (defcustom org-todo-keywords '("TODO" "DONE") |
| 218 | "List of TODO entry keywords.\\<org-mode-map> | 227 | "List of TODO entry keywords. |
| 219 | By default, this is '(\"TODO\" \"DONE\"). The last entry in the list is | 228 | \\<org-mode-map>By default, this is '(\"TODO\" \"DONE\"). The last entry in the list is |
| 220 | considered to mean that the entry is \"done\". All the other mean that | 229 | considered to mean that the entry is \"done\". All the other mean that |
| 221 | action is required, and will make the entry show up in todo lists, diaries | 230 | action is required, and will make the entry show up in todo lists, diaries |
| 222 | etc. | 231 | etc. |
| @@ -228,8 +237,8 @@ Changes become only effective after restarting Emacs." | |||
| 228 | :type '(repeat (string :tag "Keyword"))) | 237 | :type '(repeat (string :tag "Keyword"))) |
| 229 | 238 | ||
| 230 | (defcustom org-todo-interpretation 'sequence | 239 | (defcustom org-todo-interpretation 'sequence |
| 231 | "Controls how TODO keywords are interpreted.\\<org-mode-map> | 240 | "Controls how TODO keywords are interpreted. |
| 232 | Possible values are `sequence' and `type'. | 241 | \\<org-mode-map>Possible values are `sequence' and `type'. |
| 233 | This variable is only relevant if `org-todo-keywords' contains more than two | 242 | This variable is only relevant if `org-todo-keywords' contains more than two |
| 234 | states. There are two ways how these keywords can be used: | 243 | states. There are two ways how these keywords can be used: |
| 235 | 244 | ||
| @@ -256,7 +265,7 @@ RELAXED. If you later return to this entry and press \\[org-todo] again, | |||
| 256 | RELAXED will not be changed REMIND, but directly to DONE. | 265 | RELAXED will not be changed REMIND, but directly to DONE. |
| 257 | 266 | ||
| 258 | You can create a large number of types. To initially select a | 267 | You can create a large number of types. To initially select a |
| 259 | type, it is then best to use C-u \\[org-todo] in order to specify the | 268 | type, it is then best to use \\[universal-argument] \\[org-todo] in order to specify the |
| 260 | type with completion. Of course, you can also type the keyword | 269 | type with completion. Of course, you can also type the keyword |
| 261 | directly into the buffer. M-TAB completes TODO keywords at the | 270 | directly into the buffer. M-TAB completes TODO keywords at the |
| 262 | beginning of a headline." | 271 | beginning of a headline." |
| @@ -304,7 +313,7 @@ Changes become only effective after restarting Emacs." | |||
| 304 | (defcustom org-after-todo-state-change-hook nil | 313 | (defcustom org-after-todo-state-change-hook nil |
| 305 | "Hook which is run after the state of a TODO item was changed. | 314 | "Hook which is run after the state of a TODO item was changed. |
| 306 | The new state (a string with a todo keyword, or nil) is available in the | 315 | The new state (a string with a todo keyword, or nil) is available in the |
| 307 | lisp variable `state'." | 316 | Lisp variable `state'." |
| 308 | :group 'org-keywords | 317 | :group 'org-keywords |
| 309 | :type 'hook) | 318 | :type 'hook) |
| 310 | 319 | ||
| @@ -313,7 +322,7 @@ lisp variable `state'." | |||
| 313 | "Do TODO items have priorities?") | 322 | "Do TODO items have priorities?") |
| 314 | (make-variable-buffer-local 'org-todo-kwd-priority-p) | 323 | (make-variable-buffer-local 'org-todo-kwd-priority-p) |
| 315 | (defvar org-todo-kwd-max-priority nil | 324 | (defvar org-todo-kwd-max-priority nil |
| 316 | "Maximum priority of TODO items") | 325 | "Maximum priority of TODO items.") |
| 317 | (make-variable-buffer-local 'org-todo-kwd-max-priority) | 326 | (make-variable-buffer-local 'org-todo-kwd-max-priority) |
| 318 | (defvar org-ds-keyword-length 12 | 327 | (defvar org-ds-keyword-length 12 |
| 319 | "Maximum length of the Deadline and SCHEDULED keywords.") | 328 | "Maximum length of the Deadline and SCHEDULED keywords.") |
| @@ -352,6 +361,15 @@ lisp variable `state'." | |||
| 352 | "Matches the SCHEDULED keyword together with a time stamp.") | 361 | "Matches the SCHEDULED keyword together with a time stamp.") |
| 353 | (make-variable-buffer-local 'org-scheduled-time-regexp) | 362 | (make-variable-buffer-local 'org-scheduled-time-regexp) |
| 354 | 363 | ||
| 364 | (defvar org-category nil | ||
| 365 | "Variable used by org files to set a category for agenda display. | ||
| 366 | Such files should use a file variable to set it, for example | ||
| 367 | |||
| 368 | -*- mode: org; org-category: \"ELisp\" | ||
| 369 | |||
| 370 | If the file does not specify a category, the file's base name | ||
| 371 | is used instead.") | ||
| 372 | |||
| 355 | (defun org-set-regexps-and-options () | 373 | (defun org-set-regexps-and-options () |
| 356 | "Precompute regular expressions for current buffer." | 374 | "Precompute regular expressions for current buffer." |
| 357 | (when (eq major-mode 'org-mode) | 375 | (when (eq major-mode 'org-mode) |
| @@ -359,8 +377,8 @@ lisp variable `state'." | |||
| 359 | '("CATEGORY" "SEQ_TODO" "PRI_TODO" "TYP_TODO" "STARTUP"))) | 377 | '("CATEGORY" "SEQ_TODO" "PRI_TODO" "TYP_TODO" "STARTUP"))) |
| 360 | (splitre "[ \t]+") | 378 | (splitre "[ \t]+") |
| 361 | kwds int key value cat) | 379 | kwds int key value cat) |
| 362 | (save-restriction | 380 | (save-excursion |
| 363 | (save-excursion | 381 | (save-restriction |
| 364 | (widen) | 382 | (widen) |
| 365 | (goto-char (point-min)) | 383 | (goto-char (point-min)) |
| 366 | (while (re-search-forward re nil t) | 384 | (while (re-search-forward re nil t) |
| @@ -383,7 +401,7 @@ lisp variable `state'." | |||
| 383 | (let ((opts (org-split-string value splitre)) | 401 | (let ((opts (org-split-string value splitre)) |
| 384 | (set '(("fold" org-startup-folded t) | 402 | (set '(("fold" org-startup-folded t) |
| 385 | ("nofold" org-startup-folded nil) | 403 | ("nofold" org-startup-folded nil) |
| 386 | ("content" org-startup-folded 'content) | 404 | ("content" org-startup-folded content) |
| 387 | ("dlcheck" org-startup-with-deadline-check t) | 405 | ("dlcheck" org-startup-with-deadline-check t) |
| 388 | ("nodlcheck" org-startup-with-deadline-check nil))) | 406 | ("nodlcheck" org-startup-with-deadline-check nil))) |
| 389 | l var val) | 407 | l var val) |
| @@ -515,8 +533,7 @@ the entries for specific days." | |||
| 515 | :type 'boolean) | 533 | :type 'boolean) |
| 516 | 534 | ||
| 517 | (defcustom org-agenda-include-diary nil | 535 | (defcustom org-agenda-include-diary nil |
| 518 | "Non-nil means, when preparing the agenda, also get the | 536 | "If non-nil, include in the agenda entries from the Emacs Calendar's diary." |
| 519 | entries from the emacs calendars diary." | ||
| 520 | :group 'org-agenda | 537 | :group 'org-agenda |
| 521 | :type 'boolean) | 538 | :type 'boolean) |
| 522 | 539 | ||
| @@ -566,6 +583,43 @@ categories by priority." | |||
| 566 | (const priority-up) | 583 | (const priority-up) |
| 567 | (const priority-down)))) | 584 | (const priority-down)))) |
| 568 | 585 | ||
| 586 | (defcustom org-agenda-prefix-format " %-12:c% s" | ||
| 587 | "Format specification for the prefix of items in the agenda buffer. | ||
| 588 | This format works similar to a printf format, with the following meaning: | ||
| 589 | |||
| 590 | %c the category of the item, \"Diary\" for entries from the diary, or | ||
| 591 | as given by the CATEGORY keyword or derived from the file name. | ||
| 592 | %t the time-of-day specification if one applies to the entry, in the | ||
| 593 | format HH:MM | ||
| 594 | %s Scheduling/Deadline information, a short string | ||
| 595 | |||
| 596 | In addition to the normal printf field modifiers like field width and | ||
| 597 | padding instructions, in this format you can also add an additional | ||
| 598 | punctuation or whitespace character just before the final format letter. | ||
| 599 | This character will be appended to the field value if the value is not | ||
| 600 | empty. For example, the format \"%-12:c\" leads to \"Diary: \" if | ||
| 601 | the category is \"Diary\". If the category were be empty, no additional | ||
| 602 | colon would be interted. | ||
| 603 | |||
| 604 | Including `%t' in the format string leads to a double time specification | ||
| 605 | because the headline/diary item will contain the time specification as | ||
| 606 | well. However, using `%t' in the format will result in a canonical 24 | ||
| 607 | hour time specification at a consistent position in the prefix, while the | ||
| 608 | time specification in the headline/diary item may be at any position and in | ||
| 609 | various formats. | ||
| 610 | Example: | ||
| 611 | (setq org-agenda-prefix-format \" %-12:c% t% s\")" | ||
| 612 | :type 'string | ||
| 613 | :group 'org-agenda) | ||
| 614 | |||
| 615 | (defcustom org-timeline-prefix-format " % s" | ||
| 616 | "Like `org-agenda-prefix-format', but for the timeline of a single file." | ||
| 617 | :type 'string | ||
| 618 | :group 'org-agenda) | ||
| 619 | |||
| 620 | (defvar org-prefix-format-compiled nil | ||
| 621 | "The compiled version of `org-???-prefix-format'.") | ||
| 622 | |||
| 569 | (defcustom org-sort-agenda-notime-is-late t | 623 | (defcustom org-sort-agenda-notime-is-late t |
| 570 | "Non-nil means, items without time are considered late. | 624 | "Non-nil means, items without time are considered late. |
| 571 | This is only relevant for sorting. When t, items which have no explicit | 625 | This is only relevant for sorting. When t, items which have no explicit |
| @@ -574,15 +628,6 @@ do have a time. When nil, the default time is before 0:00." | |||
| 574 | :group 'org-agenda | 628 | :group 'org-agenda |
| 575 | :type 'boolean) | 629 | :type 'boolean) |
| 576 | 630 | ||
| 577 | (defvar org-category nil | ||
| 578 | "Variable used by org files to set a category for agenda display. | ||
| 579 | Such files should use a file variable to set it, for example | ||
| 580 | |||
| 581 | -*- mode: org; org-category: \"ELisp\" | ||
| 582 | |||
| 583 | If the file does not specify a category, the file's base name | ||
| 584 | is used instead.") | ||
| 585 | |||
| 586 | (defgroup org-structure nil | 631 | (defgroup org-structure nil |
| 587 | "Options concerning structure editing in Org-mode." | 632 | "Options concerning structure editing in Org-mode." |
| 588 | :tag "Org Structure" | 633 | :tag "Org Structure" |
| @@ -647,7 +692,10 @@ unnecessary clutter." | |||
| 647 | 692 | ||
| 648 | (defcustom org-allow-space-in-links t | 693 | (defcustom org-allow-space-in-links t |
| 649 | "Non-nil means, file names in links may contain space characters. | 694 | "Non-nil means, file names in links may contain space characters. |
| 650 | When nil, it becomes possible to put several links into a line." | 695 | When nil, it becomes possible to put several links into a line. |
| 696 | Note that in tables, a link never extends accross fields, so in a table | ||
| 697 | it is always possible to put several links into a line. | ||
| 698 | Changing this varable requires a re-launch of Emacs of become effective." | ||
| 651 | :group 'org-link | 699 | :group 'org-link |
| 652 | :type 'boolean) | 700 | :type 'boolean) |
| 653 | 701 | ||
| @@ -667,7 +715,7 @@ The command `org-store-link' adds a link pointing to the current | |||
| 667 | location to an internal list. These links accumulate during a session. | 715 | location to an internal list. These links accumulate during a session. |
| 668 | The command `org-insert-link' can be used to insert links into any | 716 | The command `org-insert-link' can be used to insert links into any |
| 669 | Org-mode file (offering completion for all stored links). When this | 717 | Org-mode file (offering completion for all stored links). When this |
| 670 | option is nil, every link which has been inserted once using `C-c C-l' | 718 | option is nil, every link which has been inserted once using \\[org-insert-link] |
| 671 | will be removed from the list, to make completing the unused links | 719 | will be removed from the list, to make completing the unused links |
| 672 | more efficient." | 720 | more efficient." |
| 673 | :group 'org-link | 721 | :group 'org-link |
| @@ -682,15 +730,15 @@ When following a link with Emacs, it may often be useful to display | |||
| 682 | this link in another window or frame. This variable can be used to | 730 | this link in another window or frame. This variable can be used to |
| 683 | set this up for the different types of links. | 731 | set this up for the different types of links. |
| 684 | For VM, use any of | 732 | For VM, use any of |
| 685 | vm-visit-folder | 733 | `vm-visit-folder' |
| 686 | vm-visit-folder-other-frame | 734 | `vm-visit-folder-other-frame' |
| 687 | For Gnus, use any of | 735 | For Gnus, use any of |
| 688 | gnus | 736 | `gnus' |
| 689 | gnus-other-frame | 737 | `gnus-other-frame' |
| 690 | For FILE, use any of | 738 | For FILE, use any of |
| 691 | find-file | 739 | `find-file' |
| 692 | find-file-other-window | 740 | `find-file-other-window' |
| 693 | find-file-other-frame | 741 | `find-file-other-frame' |
| 694 | For the calendar, use the variable `calendar-setup'. | 742 | For the calendar, use the variable `calendar-setup'. |
| 695 | For BBDB, it is currently only possible to display the matches in | 743 | For BBDB, it is currently only possible to display the matches in |
| 696 | another window." | 744 | another window." |
| @@ -792,10 +840,10 @@ extension. The entries in this list are cons cells with a file extension | |||
| 792 | and the corresponding command. Possible values for the command are: | 840 | and the corresponding command. Possible values for the command are: |
| 793 | `emacs' The file will be visited by the current Emacs process. | 841 | `emacs' The file will be visited by the current Emacs process. |
| 794 | `default' Use the default application for this file type. | 842 | `default' Use the default application for this file type. |
| 795 | string A command to be executed by a shell. %s will be replaced | 843 | string A command to be executed by a shell; %s will be replaced |
| 796 | by the path to the file. | 844 | by the path to the file. |
| 797 | sexp A lisp form which will be evaluated. The file path will | 845 | sexp A Lisp form which will be evaluated. The file path will |
| 798 | be available in the lisp variable `file'. | 846 | be available in the Lisp variable `file'. |
| 799 | For more examples, see the system specific constants | 847 | For more examples, see the system specific constants |
| 800 | `org-file-apps-defaults-macosx' | 848 | `org-file-apps-defaults-macosx' |
| 801 | `org-file-apps-defaults-windowsnt' | 849 | `org-file-apps-defaults-windowsnt' |
| @@ -1076,7 +1124,7 @@ This option can also be set with the +OPTIONS line, e.g. \"::nil\"." | |||
| 1076 | :type 'boolean) | 1124 | :type 'boolean) |
| 1077 | 1125 | ||
| 1078 | (defcustom org-export-with-tables t | 1126 | (defcustom org-export-with-tables t |
| 1079 | "Non-nil means, lines starting with \"|\" define a table | 1127 | "If non-nil, lines starting with \"|\" define a table |
| 1080 | For example: | 1128 | For example: |
| 1081 | 1129 | ||
| 1082 | | Name | Address | Birthday | | 1130 | | Name | Address | Birthday | |
| @@ -1150,7 +1198,7 @@ This option can also be set with the +OPTIONS line, e.g. \"TeX:nil\"." | |||
| 1150 | :type 'boolean) | 1198 | :type 'boolean) |
| 1151 | 1199 | ||
| 1152 | (defcustom org-export-html-with-timestamp nil | 1200 | (defcustom org-export-html-with-timestamp nil |
| 1153 | "Non-nil means, write `org-export-html-html-helper-timestamp' | 1201 | "If non-nil, write `org-export-html-html-helper-timestamp' |
| 1154 | into the exported html text. Otherwise, the buffer will just be saved | 1202 | into the exported html text. Otherwise, the buffer will just be saved |
| 1155 | to a file." | 1203 | to a file." |
| 1156 | :group 'org-export | 1204 | :group 'org-export |
| @@ -1348,6 +1396,7 @@ When this is non-nil, the headline after the keyword is set to the | |||
| 1348 | (defvar org-cursor-color) | 1396 | (defvar org-cursor-color) |
| 1349 | (defvar org-time-was-given) | 1397 | (defvar org-time-was-given) |
| 1350 | (defvar org-ts-what) | 1398 | (defvar org-ts-what) |
| 1399 | (defvar mark-active) | ||
| 1351 | (defvar timecnt) | 1400 | (defvar timecnt) |
| 1352 | (defvar levels-open) | 1401 | (defvar levels-open) |
| 1353 | (defvar title) | 1402 | (defvar title) |
| @@ -1383,6 +1432,17 @@ When this is non-nil, the headline after the keyword is set to the | |||
| 1383 | (defvar org-struct-menu) | 1432 | (defvar org-struct-menu) |
| 1384 | (defvar org-org-menu) | 1433 | (defvar org-org-menu) |
| 1385 | 1434 | ||
| 1435 | ;; We use a before-change function to check if a table might need | ||
| 1436 | ;; an update. | ||
| 1437 | (defvar org-table-may-need-update t | ||
| 1438 | "Indicates of a table might need an update. | ||
| 1439 | This variable is set by `org-before-change-function'. `org-table-align' | ||
| 1440 | sets it back to nil.") | ||
| 1441 | |||
| 1442 | (defvar org-mode-hook nil) | ||
| 1443 | (defvar org-inhibit-startup nil) ; Dynamically-scoped param. | ||
| 1444 | |||
| 1445 | |||
| 1386 | ;;;###autoload | 1446 | ;;;###autoload |
| 1387 | (defun org-mode (&optional arg) | 1447 | (defun org-mode (&optional arg) |
| 1388 | "Outline-based notes management and organizer, alias | 1448 | "Outline-based notes management and organizer, alias |
| @@ -1437,14 +1497,15 @@ The following commands are available: | |||
| 1437 | (goto-char (point-min)) | 1497 | (goto-char (point-min)) |
| 1438 | (insert " -*- mode: org -*-\n\n"))) | 1498 | (insert " -*- mode: org -*-\n\n"))) |
| 1439 | (run-hooks 'org-mode-hook) | 1499 | (run-hooks 'org-mode-hook) |
| 1440 | (unless (boundp 'org-inhibit-startup) | 1500 | (unless org-inhibit-startup |
| 1441 | (if org-startup-with-deadline-check | 1501 | (if org-startup-with-deadline-check |
| 1442 | (call-interactively 'org-check-deadlines) | 1502 | (call-interactively 'org-check-deadlines) |
| 1443 | (cond | 1503 | (cond |
| 1444 | ((eq org-startup-folded t) | 1504 | ((eq org-startup-folded t) |
| 1445 | (org-cycle)) | 1505 | (org-cycle '(4))) |
| 1446 | ((eq org-startup-folded 'contents) | 1506 | ((eq org-startup-folded 'content) |
| 1447 | (org-cycle) (org-cycle)))))) | 1507 | (let ((this-command 'org-cycle) (last-command 'org-cycle)) |
| 1508 | (org-cycle '(4)) (org-cycle '(4)))))))) | ||
| 1448 | 1509 | ||
| 1449 | ;;; Font-Lock stuff | 1510 | ;;; Font-Lock stuff |
| 1450 | 1511 | ||
| @@ -1456,10 +1517,13 @@ The following commands are available: | |||
| 1456 | 1517 | ||
| 1457 | (require 'font-lock) | 1518 | (require 'font-lock) |
| 1458 | 1519 | ||
| 1520 | (defconst org-non-link-chars "\t\n\r|") | ||
| 1459 | (defconst org-link-regexp | 1521 | (defconst org-link-regexp |
| 1460 | (if org-allow-space-in-links | 1522 | (if org-allow-space-in-links |
| 1461 | "\\(https?\\|ftp\\|mailto\\|file\\|news\\|bbdb\\|vm\\|wl\\|rmail\\|gnus\\|shell\\):\\([^\t\n\r]+[^ \t\n\r]\\)" | 1523 | (concat |
| 1462 | "\\(https?\\|ftp\\|mailto\\|file\\|news\\|bbdb\\|vm\\|wl\\|rmail\\|gnus\\|shell\\):\\([^ \t\n\r]+\\)" | 1524 | "\\(https?\\|ftp\\|mailto|\\|file\\|news\\|bbdb\\|vm\\|wl\\|rmail\\|gnus\\|shell\\):\\([^" org-non-link-chars "]+[^ " org-non-link-chars "]\\)") |
| 1525 | (concat | ||
| 1526 | "\\(https?\\|ftp\\|mailto\\|file\\|news\\|bbdb\\|vm\\|wl\\|rmail\\|gnus\\|shell\\):\\([^ " org-non-link-chars "]+\\)") | ||
| 1463 | ) | 1527 | ) |
| 1464 | "Regular expression for matching links.") | 1528 | "Regular expression for matching links.") |
| 1465 | (defconst org-ts-lengths | 1529 | (defconst org-ts-lengths |
| @@ -1502,6 +1566,8 @@ The following commands are available: | |||
| 1502 | (org-back-to-heading t) | 1566 | (org-back-to-heading t) |
| 1503 | (- (match-end 0) (match-beginning 0)))) | 1567 | (- (match-end 0) (match-beginning 0)))) |
| 1504 | 1568 | ||
| 1569 | (defvar org-font-lock-keywords nil) | ||
| 1570 | |||
| 1505 | (defun org-set-font-lock-defaults () | 1571 | (defun org-set-font-lock-defaults () |
| 1506 | (let ((org-font-lock-extra-keywords | 1572 | (let ((org-font-lock-extra-keywords |
| 1507 | (list | 1573 | (list |
| @@ -1550,13 +1616,10 @@ The following commands are available: | |||
| 1550 | '(org-font-lock-keywords t nil nil backward-paragraph)) | 1616 | '(org-font-lock-keywords t nil nil backward-paragraph)) |
| 1551 | (kill-local-variable 'font-lock-keywords) nil)) | 1617 | (kill-local-variable 'font-lock-keywords) nil)) |
| 1552 | 1618 | ||
| 1553 | (defvar org-font-lock-keywords nil) | ||
| 1554 | |||
| 1555 | (defun org-unfontify-region (beg end &optional maybe_loudly) | 1619 | (defun org-unfontify-region (beg end &optional maybe_loudly) |
| 1556 | "Remove fontification and activation overlays from links." | 1620 | "Remove fontification and activation overlays from links." |
| 1557 | (font-lock-default-unfontify-region beg end) | 1621 | (font-lock-default-unfontify-region beg end) |
| 1558 | (let* ((modified (buffer-modified-p)) ;; FIXME: Why did I add this??? | 1622 | (let* ((buffer-undo-list t) |
| 1559 | (buffer-undo-list t) | ||
| 1560 | (inhibit-read-only t) (inhibit-point-motion-hooks t) | 1623 | (inhibit-read-only t) (inhibit-point-motion-hooks t) |
| 1561 | (inhibit-modification-hooks t) | 1624 | (inhibit-modification-hooks t) |
| 1562 | deactivate-mark buffer-file-name buffer-file-truename) | 1625 | deactivate-mark buffer-file-name buffer-file-truename) |
| @@ -1651,15 +1714,15 @@ The following commands are available: | |||
| 1651 | (save-excursion | 1714 | (save-excursion |
| 1652 | (org-back-to-heading) | 1715 | (org-back-to-heading) |
| 1653 | (outline-up-heading arg) | 1716 | (outline-up-heading arg) |
| 1654 | (show-subtree))) | 1717 | (org-show-subtree))) |
| 1655 | 1718 | ||
| 1656 | ((save-excursion (beginning-of-line 1) (looking-at outline-regexp)) | 1719 | ((save-excursion (beginning-of-line 1) (looking-at outline-regexp)) |
| 1657 | ;; At a heading: rotate between three different views | 1720 | ;; At a heading: rotate between three different views |
| 1658 | (org-back-to-heading) | 1721 | (org-back-to-heading) |
| 1659 | (let ((goal-column 0) beg eoh eol eos nxh) | 1722 | (let ((goal-column 0) eoh eol eos) |
| 1660 | ;; First, some boundaries | 1723 | ;; First, some boundaries |
| 1661 | (save-excursion | 1724 | (save-excursion |
| 1662 | (org-back-to-heading) (setq beg (point)) | 1725 | (org-back-to-heading) |
| 1663 | (save-excursion | 1726 | (save-excursion |
| 1664 | (beginning-of-line 2) | 1727 | (beginning-of-line 2) |
| 1665 | (while (and (not (eobp)) ;; this is like `next-line' | 1728 | (while (and (not (eobp)) ;; this is like `next-line' |
| @@ -1667,7 +1730,7 @@ The following commands are available: | |||
| 1667 | (beginning-of-line 2)) (setq eol (point))) | 1730 | (beginning-of-line 2)) (setq eol (point))) |
| 1668 | (outline-end-of-heading) (setq eoh (point)) | 1731 | (outline-end-of-heading) (setq eoh (point)) |
| 1669 | (outline-end-of-subtree) (setq eos (point)) | 1732 | (outline-end-of-subtree) (setq eos (point)) |
| 1670 | (outline-next-heading) (setq nxh (point))) | 1733 | (outline-next-heading)) |
| 1671 | ;; Find out what to do next and set `this-command' | 1734 | ;; Find out what to do next and set `this-command' |
| 1672 | (cond | 1735 | (cond |
| 1673 | ((= eos eoh) | 1736 | ((= eos eoh) |
| @@ -1676,7 +1739,7 @@ The following commands are available: | |||
| 1676 | (setq org-cycle-subtree-status nil)) | 1739 | (setq org-cycle-subtree-status nil)) |
| 1677 | ((>= eol eos) | 1740 | ((>= eol eos) |
| 1678 | ;; Entire subtree is hidden in one line: open it | 1741 | ;; Entire subtree is hidden in one line: open it |
| 1679 | (show-entry) | 1742 | (org-show-entry) |
| 1680 | (show-children) | 1743 | (show-children) |
| 1681 | (message "CHILDREN") | 1744 | (message "CHILDREN") |
| 1682 | (setq org-cycle-subtree-status 'children) | 1745 | (setq org-cycle-subtree-status 'children) |
| @@ -1684,7 +1747,7 @@ The following commands are available: | |||
| 1684 | ((and (eq last-command this-command) | 1747 | ((and (eq last-command this-command) |
| 1685 | (eq org-cycle-subtree-status 'children)) | 1748 | (eq org-cycle-subtree-status 'children)) |
| 1686 | ;; We just showed the children, now show everything. | 1749 | ;; We just showed the children, now show everything. |
| 1687 | (show-subtree) | 1750 | (org-show-subtree) |
| 1688 | (message "SUBTREE") | 1751 | (message "SUBTREE") |
| 1689 | (setq org-cycle-subtree-status 'subtree) | 1752 | (setq org-cycle-subtree-status 'subtree) |
| 1690 | (run-hook-with-args 'org-cycle-hook 'subtree)) | 1753 | (run-hook-with-args 'org-cycle-hook 'subtree)) |
| @@ -1733,9 +1796,9 @@ This function is the default value of the hook `org-cycle-hook'." | |||
| 1733 | "Move cursor to the first headline and recenter the headline. | 1796 | "Move cursor to the first headline and recenter the headline. |
| 1734 | Optional argument N means, put the headline into the Nth line of the window." | 1797 | Optional argument N means, put the headline into the Nth line of the window." |
| 1735 | (goto-char (point-min)) | 1798 | (goto-char (point-min)) |
| 1736 | (re-search-forward (concat "^" outline-regexp)) | 1799 | (when (re-search-forward (concat "^" outline-regexp) nil t) |
| 1737 | (beginning-of-line) | 1800 | (beginning-of-line) |
| 1738 | (recenter (prefix-numeric-value N))) | 1801 | (recenter (prefix-numeric-value N)))) |
| 1739 | 1802 | ||
| 1740 | (defvar org-goto-window-configuration nil) | 1803 | (defvar org-goto-window-configuration nil) |
| 1741 | (defvar org-goto-marker nil) | 1804 | (defvar org-goto-marker nil) |
| @@ -1836,9 +1899,9 @@ or nil." | |||
| 1836 | current-prefix-arg arg) | 1899 | current-prefix-arg arg) |
| 1837 | (throw 'exit nil)) | 1900 | (throw 'exit nil)) |
| 1838 | 1901 | ||
| 1839 | (defun org-goto-left (&optional arg) | 1902 | (defun org-goto-left () |
| 1840 | "Finish org-goto by going to the new location." | 1903 | "Finish org-goto by going to the new location." |
| 1841 | (interactive "P") | 1904 | (interactive) |
| 1842 | (if (org-on-heading-p) | 1905 | (if (org-on-heading-p) |
| 1843 | (progn | 1906 | (progn |
| 1844 | (beginning-of-line 1) | 1907 | (beginning-of-line 1) |
| @@ -1847,9 +1910,9 @@ or nil." | |||
| 1847 | (throw 'exit nil)) | 1910 | (throw 'exit nil)) |
| 1848 | (error "Not on a heading"))) | 1911 | (error "Not on a heading"))) |
| 1849 | 1912 | ||
| 1850 | (defun org-goto-right (&optional arg) | 1913 | (defun org-goto-right () |
| 1851 | "Finish org-goto by going to the new location." | 1914 | "Finish org-goto by going to the new location." |
| 1852 | (interactive "P") | 1915 | (interactive) |
| 1853 | (if (org-on-heading-p) | 1916 | (if (org-on-heading-p) |
| 1854 | (progn | 1917 | (progn |
| 1855 | (outline-end-of-subtree) | 1918 | (outline-end-of-subtree) |
| @@ -1870,9 +1933,9 @@ or nil." | |||
| 1870 | (defvar org-ignore-region nil | 1933 | (defvar org-ignore-region nil |
| 1871 | "To temporarily disable the active region.") | 1934 | "To temporarily disable the active region.") |
| 1872 | 1935 | ||
| 1873 | (defun org-insert-heading (&optional arg) | 1936 | (defun org-insert-heading () |
| 1874 | "Insert a new heading with same depth at point." | 1937 | "Insert a new heading with same depth at point." |
| 1875 | (interactive "P") | 1938 | (interactive) |
| 1876 | (let* ((head (save-excursion | 1939 | (let* ((head (save-excursion |
| 1877 | (condition-case nil | 1940 | (condition-case nil |
| 1878 | (org-back-to-heading) | 1941 | (org-back-to-heading) |
| @@ -1903,34 +1966,36 @@ state (TODO by default). Also with prefix arg, force first state." | |||
| 1903 | (insert (car org-todo-keywords) " ") | 1966 | (insert (car org-todo-keywords) " ") |
| 1904 | (insert (match-string 2) " "))) | 1967 | (insert (match-string 2) " "))) |
| 1905 | 1968 | ||
| 1906 | (defun org-promote-subtree (&optional arg) | 1969 | (defun org-promote-subtree () |
| 1907 | "Promote the entire subtree. | 1970 | "Promote the entire subtree. |
| 1908 | See also `org-promote'." | 1971 | See also `org-promote'." |
| 1909 | (interactive "P") | 1972 | (interactive) |
| 1910 | (org-map-tree 'org-promote)) | 1973 | (save-excursion |
| 1974 | (org-map-tree 'org-promote))) | ||
| 1911 | 1975 | ||
| 1912 | (defun org-demote-subtree (&optional arg) | 1976 | (defun org-demote-subtree () |
| 1913 | "Demote the entire subtree. See `org-demote'. | 1977 | "Demote the entire subtree. See `org-demote'. |
| 1914 | See also `org-promote'." | 1978 | See also `org-promote'." |
| 1915 | (interactive "P") | 1979 | (interactive) |
| 1916 | (org-map-tree 'org-demote)) | 1980 | (save-excursion |
| 1981 | (org-map-tree 'org-demote))) | ||
| 1917 | 1982 | ||
| 1918 | (defun org-do-promote (&optional arg) | 1983 | (defun org-do-promote () |
| 1919 | "Promote the current heading higher up the tree. | 1984 | "Promote the current heading higher up the tree. |
| 1920 | If the region is active in transient-mark-mode, promote all headings | 1985 | If the region is active in t`ransient-mark-mode', promote all headings |
| 1921 | in the region." | 1986 | in the region." |
| 1922 | (interactive "P") | 1987 | (interactive) |
| 1923 | (save-excursion | 1988 | (save-excursion |
| 1924 | (if (org-region-active-p) | 1989 | (if (org-region-active-p) |
| 1925 | (org-map-region 'org-promote (region-beginning) (region-end)) | 1990 | (org-map-region 'org-promote (region-beginning) (region-end)) |
| 1926 | (org-promote))) | 1991 | (org-promote))) |
| 1927 | (org-fix-position-after-promote)) | 1992 | (org-fix-position-after-promote)) |
| 1928 | 1993 | ||
| 1929 | (defun org-do-demote (&optional arg) | 1994 | (defun org-do-demote () |
| 1930 | "Demote the current heading lower down the tree. | 1995 | "Demote the current heading lower down the tree. |
| 1931 | If the region is active in transient-mark-mode, demote all headings | 1996 | If the region is active in `transient-mark-mode', demote all headings |
| 1932 | in the region." | 1997 | in the region." |
| 1933 | (interactive "P") | 1998 | (interactive) |
| 1934 | (save-excursion | 1999 | (save-excursion |
| 1935 | (if (org-region-active-p) | 2000 | (if (org-region-active-p) |
| 1936 | (org-map-region 'org-demote (region-beginning) (region-end)) | 2001 | (org-map-region 'org-demote (region-beginning) (region-end)) |
| @@ -1945,7 +2010,7 @@ in the region." | |||
| 1945 | 2010 | ||
| 1946 | (defun org-promote () | 2011 | (defun org-promote () |
| 1947 | "Promote the current heading higher up the tree. | 2012 | "Promote the current heading higher up the tree. |
| 1948 | If the region is active in transient-mark-mode, promote all headings | 2013 | If the region is active in `transient-mark-mode', promote all headings |
| 1949 | in the region." | 2014 | in the region." |
| 1950 | (org-back-to-heading t) | 2015 | (org-back-to-heading t) |
| 1951 | (let* ((level (save-match-data (funcall outline-level))) | 2016 | (let* ((level (save-match-data (funcall outline-level))) |
| @@ -1957,7 +2022,7 @@ in the region." | |||
| 1957 | 2022 | ||
| 1958 | (defun org-demote () | 2023 | (defun org-demote () |
| 1959 | "Demote the current heading lower down the tree. | 2024 | "Demote the current heading lower down the tree. |
| 1960 | If the region is active in transient-mark-mode, demote all headings | 2025 | If the region is active in `transient-mark-mode', demote all headings |
| 1961 | in the region." | 2026 | in the region." |
| 1962 | (org-back-to-heading t) | 2027 | (org-back-to-heading t) |
| 1963 | (let* ((level (save-match-data (funcall outline-level))) | 2028 | (let* ((level (save-match-data (funcall outline-level))) |
| @@ -2066,17 +2131,17 @@ ring. We need it to check if the kill was created by `org-copy-subtree'.") | |||
| 2066 | "Was the last copied subtree folded? | 2131 | "Was the last copied subtree folded? |
| 2067 | This is used to fold the tree back after pasting.") | 2132 | This is used to fold the tree back after pasting.") |
| 2068 | 2133 | ||
| 2069 | (defun org-cut-subtree (&optional arg) | 2134 | (defun org-cut-subtree () |
| 2070 | "Cut the current subtree into the clipboard. | 2135 | "Cut the current subtree into the clipboard. |
| 2071 | This is a short-hand for marking the subtree and then cutting it." | 2136 | This is a short-hand for marking the subtree and then cutting it." |
| 2072 | (interactive "p") | 2137 | (interactive) |
| 2073 | (org-copy-subtree arg 'cut)) | 2138 | (org-copy-subtree 'cut)) |
| 2074 | 2139 | ||
| 2075 | (defun org-copy-subtree (&optional arg cut) | 2140 | (defun org-copy-subtree (&optional cut) |
| 2076 | "Cut the current subtree into the clipboard. | 2141 | "Cut the current subtree into the clipboard. |
| 2077 | This is a short-hand for marking the subtree and then copying it. | 2142 | This is a short-hand for marking the subtree and then copying it. |
| 2078 | If CUT is non nil, actually cut the subtree." | 2143 | If CUT is non nil, actually cut the subtree." |
| 2079 | (interactive "p") | 2144 | (interactive) |
| 2080 | (let (beg end folded) | 2145 | (let (beg end folded) |
| 2081 | (org-back-to-heading) | 2146 | (org-back-to-heading) |
| 2082 | (setq beg (point)) | 2147 | (setq beg (point)) |
| @@ -2338,7 +2403,7 @@ prefix arg, switch to that state." | |||
| 2338 | ;; Fixup cursor location if close to the keyword | 2403 | ;; Fixup cursor location if close to the keyword |
| 2339 | (if (and (outline-on-heading-p) | 2404 | (if (and (outline-on-heading-p) |
| 2340 | (not (bolp)) | 2405 | (not (bolp)) |
| 2341 | (save-excursion (goto-char (point-at-bol)) | 2406 | (save-excursion (beginning-of-line 1) |
| 2342 | (looking-at org-todo-line-regexp)) | 2407 | (looking-at org-todo-line-regexp)) |
| 2343 | (< (point) (+ 2 (or (match-end 2) (match-end 1))))) | 2408 | (< (point) (+ 2 (or (match-end 2) (match-end 1))))) |
| 2344 | (progn | 2409 | (progn |
| @@ -2681,7 +2746,7 @@ This is used by `org-read-date' in a temporary keymap for the calendar buffer." | |||
| 2681 | A deadline is considered due if it happens within `org-deadline-warning-days' | 2746 | A deadline is considered due if it happens within `org-deadline-warning-days' |
| 2682 | days from today's date. If the deadline appears in an entry marked DONE, | 2747 | days from today's date. If the deadline appears in an entry marked DONE, |
| 2683 | it is not shown. The prefix arg NDAYS can be used to test that many | 2748 | it is not shown. The prefix arg NDAYS can be used to test that many |
| 2684 | days. If the prefix is a raw C-u prefix, all deadlines are shown." | 2749 | days. If the prefix is a raw \\[universal-argument] prefix, all deadlines are shown." |
| 2685 | (interactive "P") | 2750 | (interactive "P") |
| 2686 | (let* ((org-warn-days | 2751 | (let* ((org-warn-days |
| 2687 | (cond | 2752 | (cond |
| @@ -2718,6 +2783,7 @@ days in order to avoid rounding problems." | |||
| 2718 | (error "Not at a time-stamp range, and none found in current line."))) | 2783 | (error "Not at a time-stamp range, and none found in current line."))) |
| 2719 | (let* ((ts1 (match-string 1)) | 2784 | (let* ((ts1 (match-string 1)) |
| 2720 | (ts2 (match-string 2)) | 2785 | (ts2 (match-string 2)) |
| 2786 | (havetime (or (> (length ts1) 15) (> (length ts2) 15))) | ||
| 2721 | (match-end (match-end 0)) | 2787 | (match-end (match-end 0)) |
| 2722 | (time1 (org-time-string-to-time ts1)) | 2788 | (time1 (org-time-string-to-time ts1)) |
| 2723 | (time2 (org-time-string-to-time ts2)) | 2789 | (time2 (org-time-string-to-time ts2)) |
| @@ -2725,17 +2791,27 @@ days in order to avoid rounding problems." | |||
| 2725 | (t2 (time-to-seconds time2)) | 2791 | (t2 (time-to-seconds time2)) |
| 2726 | (diff (abs (- t2 t1))) | 2792 | (diff (abs (- t2 t1))) |
| 2727 | (negative (< (- t2 t1) 0)) | 2793 | (negative (< (- t2 t1) 0)) |
| 2728 | (ys (floor (* 365 24 60 60))) | 2794 | ;; (ys (floor (* 365 24 60 60))) |
| 2729 | (ds (* 24 60 60)) | 2795 | (ds (* 24 60 60)) |
| 2730 | (hs (* 60 60)) | 2796 | (hs (* 60 60)) |
| 2731 | (fy "%dy %dd %02d:%02d") | 2797 | (fy "%dy %dd %02d:%02d") |
| 2798 | (fy1 "%dy %dd") | ||
| 2732 | (fd "%dd %02d:%02d") | 2799 | (fd "%dd %02d:%02d") |
| 2800 | (fd1 "%dd") | ||
| 2733 | (fh "%02d:%02d") | 2801 | (fh "%02d:%02d") |
| 2734 | y d h m align) | 2802 | y d h m align) |
| 2735 | (setq y (floor (/ diff ys)) diff (mod diff ys) | 2803 | ;; FIXME: Should I re-introduce years, make year refer to same date? |
| 2736 | d (floor (/ diff ds)) diff (mod diff ds) | 2804 | ;; This would be the only useful way to have years, actually. |
| 2737 | h (floor (/ diff hs)) diff (mod diff hs) | 2805 | (if havetime |
| 2738 | m (floor (/ diff 60))) | 2806 | (setq ; y (floor (/ diff ys)) diff (mod diff ys) |
| 2807 | y 0 | ||
| 2808 | d (floor (/ diff ds)) diff (mod diff ds) | ||
| 2809 | h (floor (/ diff hs)) diff (mod diff hs) | ||
| 2810 | m (floor (/ diff 60))) | ||
| 2811 | (setq ; y (floor (/ diff ys)) diff (mod diff ys) | ||
| 2812 | y 0 | ||
| 2813 | d (floor (+ (/ diff ds) 0.5)) | ||
| 2814 | h 0 m 0)) | ||
| 2739 | (if (not to-buffer) | 2815 | (if (not to-buffer) |
| 2740 | (message (org-make-tdiff-string y d h m)) | 2816 | (message (org-make-tdiff-string y d h m)) |
| 2741 | (when (org-at-table-p) | 2817 | (when (org-at-table-p) |
| @@ -2746,8 +2822,8 @@ days in order to avoid rounding problems." | |||
| 2746 | "\\( *-? *[0-9]+y\\)?\\( *[0-9]+d\\)? *[0-9][0-9]:[0-9][0-9]") | 2822 | "\\( *-? *[0-9]+y\\)?\\( *[0-9]+d\\)? *[0-9][0-9]:[0-9][0-9]") |
| 2747 | (replace-match "")) | 2823 | (replace-match "")) |
| 2748 | (if negative (insert " -")) | 2824 | (if negative (insert " -")) |
| 2749 | (if (> y 0) (insert " " (format fy y d h m)) | 2825 | (if (> y 0) (insert " " (format (if havetime fy fy1) y d h m)) |
| 2750 | (if (> d 0) (insert " " (format fd d h m)) | 2826 | (if (> d 0) (insert " " (format (if havetime fd fd1) d h m)) |
| 2751 | (insert " " (format fh h m)))) | 2827 | (insert " " (format fh h m)))) |
| 2752 | (if align (org-table-align)) | 2828 | (if align (org-table-align)) |
| 2753 | (message "Time difference inserted")))) | 2829 | (message "Time difference inserted")))) |
| @@ -2770,7 +2846,7 @@ days in order to avoid rounding problems." | |||
| 2770 | 2846 | ||
| 2771 | (defun org-parse-time-string (s) | 2847 | (defun org-parse-time-string (s) |
| 2772 | "Parse the standard Org-mode time string. | 2848 | "Parse the standard Org-mode time string. |
| 2773 | This should be a lot faster than the normal parse-time-string." | 2849 | This should be a lot faster than the normal `parse-time-string'." |
| 2774 | (if (string-match org-ts-regexp1 s) | 2850 | (if (string-match org-ts-regexp1 s) |
| 2775 | (list 0 | 2851 | (list 0 |
| 2776 | (string-to-number (or (match-string 8 s) "0")) | 2852 | (string-to-number (or (match-string 8 s) "0")) |
| @@ -2927,7 +3003,7 @@ If there is already a time stamp at the cursor position, update it." | |||
| 2927 | ;;; Define the mode | 3003 | ;;; Define the mode |
| 2928 | 3004 | ||
| 2929 | (defvar org-agenda-mode-map (make-sparse-keymap) | 3005 | (defvar org-agenda-mode-map (make-sparse-keymap) |
| 2930 | "Keymap for org-agenda-mode.") | 3006 | "Keymap for `org-agenda-mode'.") |
| 2931 | 3007 | ||
| 2932 | (defvar org-agenda-menu) | 3008 | (defvar org-agenda-menu) |
| 2933 | (defvar org-agenda-follow-mode nil) | 3009 | (defvar org-agenda-follow-mode nil) |
| @@ -2949,6 +3025,7 @@ The following commands are available: | |||
| 2949 | (easy-menu-add org-agenda-menu) | 3025 | (easy-menu-add org-agenda-menu) |
| 2950 | (if org-startup-truncated (setq truncate-lines t)) | 3026 | (if org-startup-truncated (setq truncate-lines t)) |
| 2951 | (add-hook 'post-command-hook 'org-agenda-post-command-hook nil 'local) | 3027 | (add-hook 'post-command-hook 'org-agenda-post-command-hook nil 'local) |
| 3028 | (add-hook 'pre-command-hook 'org-unhighlight nil 'local) | ||
| 2952 | (setq org-agenda-follow-mode nil) | 3029 | (setq org-agenda-follow-mode nil) |
| 2953 | (easy-menu-change | 3030 | (easy-menu-change |
| 2954 | '("Agenda") "Agenda Files" | 3031 | '("Agenda") "Agenda Files" |
| @@ -2968,7 +3045,7 @@ The following commands are available: | |||
| 2968 | (define-key org-agenda-mode-map "l" 'org-agenda-recenter) | 3045 | (define-key org-agenda-mode-map "l" 'org-agenda-recenter) |
| 2969 | (define-key org-agenda-mode-map "t" 'org-agenda-todo) | 3046 | (define-key org-agenda-mode-map "t" 'org-agenda-todo) |
| 2970 | (define-key org-agenda-mode-map "." 'org-agenda-goto-today) | 3047 | (define-key org-agenda-mode-map "." 'org-agenda-goto-today) |
| 2971 | (define-key org-agenda-mode-map "w" 'org-agenda-week-view) | 3048 | (define-key org-agenda-mode-map "w" 'org-agenda-toggle-week-view) |
| 2972 | (define-key org-agenda-mode-map [(shift right)] 'org-agenda-date-later) | 3049 | (define-key org-agenda-mode-map [(shift right)] 'org-agenda-date-later) |
| 2973 | (define-key org-agenda-mode-map [(shift left)] 'org-agenda-date-earlier) | 3050 | (define-key org-agenda-mode-map [(shift left)] 'org-agenda-date-earlier) |
| 2974 | 3051 | ||
| @@ -3043,7 +3120,8 @@ The following commands are available: | |||
| 3043 | ["Next Dates" org-agenda-later (local-variable-p 'starting-day)] | 3120 | ["Next Dates" org-agenda-later (local-variable-p 'starting-day)] |
| 3044 | ["Previous Dates" org-agenda-earlier (local-variable-p 'starting-day)] | 3121 | ["Previous Dates" org-agenda-earlier (local-variable-p 'starting-day)] |
| 3045 | "--" | 3122 | "--" |
| 3046 | ["Week/Day View" org-agenda-week-view (local-variable-p 'starting-day)] | 3123 | ["Week/Day View" org-agenda-toggle-week-view |
| 3124 | (local-variable-p 'starting-day)] | ||
| 3047 | ["Include Diary" org-agenda-toggle-diary | 3125 | ["Include Diary" org-agenda-toggle-diary |
| 3048 | :style toggle :selected org-agenda-include-diary :active t] | 3126 | :style toggle :selected org-agenda-include-diary :active t] |
| 3049 | "--" | 3127 | "--" |
| @@ -3060,7 +3138,7 @@ The following commands are available: | |||
| 3060 | )) | 3138 | )) |
| 3061 | 3139 | ||
| 3062 | (defvar org-agenda-markers nil | 3140 | (defvar org-agenda-markers nil |
| 3063 | "List of all currently active markers created by org-agenda") | 3141 | "List of all currently active markers created by `org-agenda'.") |
| 3064 | (defvar org-agenda-last-marker-time (time-to-seconds (current-time)) | 3142 | (defvar org-agenda-last-marker-time (time-to-seconds (current-time)) |
| 3065 | "Creation time of the last agenda marker.") | 3143 | "Creation time of the last agenda marker.") |
| 3066 | 3144 | ||
| @@ -3074,7 +3152,7 @@ no longer in use." | |||
| 3074 | m)) | 3152 | m)) |
| 3075 | 3153 | ||
| 3076 | (defun org-agenda-maybe-reset-markers (&optional force) | 3154 | (defun org-agenda-maybe-reset-markers (&optional force) |
| 3077 | "Reset markers created by org-agenda. But only if they are old enough." | 3155 | "Reset markers created by `org-agenda'. But only if they are old enough." |
| 3078 | (if (or force | 3156 | (if (or force |
| 3079 | (> (- (time-to-seconds (current-time)) | 3157 | (> (- (time-to-seconds (current-time)) |
| 3080 | org-agenda-last-marker-time) | 3158 | org-agenda-last-marker-time) |
| @@ -3106,21 +3184,23 @@ When a buffer is unmodified, it is just killed. When modified, it is saved | |||
| 3106 | (when (and (buffer-modified-p buf) | 3184 | (when (and (buffer-modified-p buf) |
| 3107 | file | 3185 | file |
| 3108 | (y-or-n-p (format "Save file %s? " file))) | 3186 | (y-or-n-p (format "Save file %s? " file))) |
| 3109 | (save-excursion | 3187 | (with-current-buffer buf (save-buffer))) |
| 3110 | (set-buffer buf) (save-buffer))) | ||
| 3111 | (kill-buffer buf)))) | 3188 | (kill-buffer buf)))) |
| 3112 | 3189 | ||
| 3190 | (defvar org-respect-restriction nil) ; Dynamically-scoped param. | ||
| 3191 | |||
| 3113 | (defun org-timeline (&optional include-all) | 3192 | (defun org-timeline (&optional include-all) |
| 3114 | "Show a time-sorted view of the entries in the current org file. | 3193 | "Show a time-sorted view of the entries in the current org file. |
| 3115 | Only entries with a time stamp of today or later will be listed. With | 3194 | Only entries with a time stamp of today or later will be listed. With |
| 3116 | one C-u prefix argument, past entries will also be listed. | 3195 | one \\[universal-argument] prefix argument, past entries will also be listed. |
| 3117 | With two C-u prefixes, all unfinished TODO items will also be shown, | 3196 | With two \\[universal-argument] prefixes, all unfinished TODO items will also be shown, |
| 3118 | under the current date. | 3197 | under the current date. |
| 3119 | If the buffer contains an active region, only check the region for | 3198 | If the buffer contains an active region, only check the region for |
| 3120 | dates." | 3199 | dates." |
| 3121 | (interactive "P") | 3200 | (interactive "P") |
| 3122 | (require 'calendar) | 3201 | (require 'calendar) |
| 3123 | (org-agenda-maybe-reset-markers 'force) | 3202 | (org-agenda-maybe-reset-markers 'force) |
| 3203 | (org-compile-prefix-format org-timeline-prefix-format) | ||
| 3124 | (let* ((dopast include-all) | 3204 | (let* ((dopast include-all) |
| 3125 | (dotodo (equal include-all '(16))) | 3205 | (dotodo (equal include-all '(16))) |
| 3126 | (entry (buffer-file-name)) | 3206 | (entry (buffer-file-name)) |
| @@ -3135,7 +3215,7 @@ dates." | |||
| 3135 | (today (time-to-days (current-time))) | 3215 | (today (time-to-days (current-time))) |
| 3136 | (org-respect-restriction t) | 3216 | (org-respect-restriction t) |
| 3137 | (past t) | 3217 | (past t) |
| 3138 | s e rtn d pos) | 3218 | s e rtn d) |
| 3139 | (setq org-agenda-redo-command | 3219 | (setq org-agenda-redo-command |
| 3140 | (list 'progn | 3220 | (list 'progn |
| 3141 | (list 'switch-to-buffer-other-window (current-buffer)) | 3221 | (list 'switch-to-buffer-other-window (current-buffer)) |
| @@ -3188,13 +3268,14 @@ dates." | |||
| 3188 | "Produce a weekly view from all files in variable `org-agenda-files'. | 3268 | "Produce a weekly view from all files in variable `org-agenda-files'. |
| 3189 | The view will be for the current week, but from the overview buffer you | 3269 | The view will be for the current week, but from the overview buffer you |
| 3190 | will be able to go to other weeks. | 3270 | will be able to go to other weeks. |
| 3191 | With one C-u prefix argument INCLUDE-ALL, all unfinished TODO items will | 3271 | With one \\[universal-argument] prefix argument INCLUDE-ALL, all unfinished TODO items will |
| 3192 | also be shown, under the current date. | 3272 | also be shown, under the current date. |
| 3193 | START-DAY defaults to TODAY, or to the most recent match for the weekday | 3273 | START-DAY defaults to TODAY, or to the most recent match for the weekday |
| 3194 | given in `org-agenda-start-on-weekday'. | 3274 | given in `org-agenda-start-on-weekday'. |
| 3195 | NDAYS defaults to `org-agenda-ndays'." | 3275 | NDAYS defaults to `org-agenda-ndays'." |
| 3196 | (interactive "P") | 3276 | (interactive "P") |
| 3197 | (org-agenda-maybe-reset-markers 'force) | 3277 | (org-agenda-maybe-reset-markers 'force) |
| 3278 | (org-compile-prefix-format org-agenda-prefix-format) | ||
| 3198 | (require 'calendar) | 3279 | (require 'calendar) |
| 3199 | (let* ((org-agenda-start-on-weekday | 3280 | (let* ((org-agenda-start-on-weekday |
| 3200 | (if (or (equal ndays 1) | 3281 | (if (or (equal ndays 1) |
| @@ -3306,31 +3387,31 @@ NDAYS defaults to `org-agenda-ndays'." | |||
| 3306 | (throw 'nextfile t)) | 3387 | (throw 'nextfile t)) |
| 3307 | (t (error "Abort")))))) | 3388 | (t (error "Abort")))))) |
| 3308 | 3389 | ||
| 3309 | (defun org-agenda-quit (arg) | 3390 | (defun org-agenda-quit () |
| 3310 | "Exit agenda by removing the window or the buffer." | 3391 | "Exit agenda by removing the window or the buffer." |
| 3311 | (interactive "P") | 3392 | (interactive) |
| 3312 | (let ((buf (current-buffer))) | 3393 | (let ((buf (current-buffer))) |
| 3313 | (if (not (one-window-p)) (delete-window)) | 3394 | (if (not (one-window-p)) (delete-window)) |
| 3314 | (kill-buffer buf) | 3395 | (kill-buffer buf) |
| 3315 | (org-agenda-maybe-reset-markers 'force))) | 3396 | (org-agenda-maybe-reset-markers 'force))) |
| 3316 | 3397 | ||
| 3317 | (defun org-agenda-exit (arg) | 3398 | (defun org-agenda-exit () |
| 3318 | "Exit agenda by removing the window or the buffer. | 3399 | "Exit agenda by removing the window or the buffer. |
| 3319 | Also kill all Org-mode buffers which have been loaded by `org-agenda'. | 3400 | Also kill all Org-mode buffers which have been loaded by `org-agenda'. |
| 3320 | Org-mode buffers visited directly by the user will not be touched." | 3401 | Org-mode buffers visited directly by the user will not be touched." |
| 3321 | (interactive "P") | 3402 | (interactive) |
| 3322 | (org-release-buffers org-agenda-new-buffers) | 3403 | (org-release-buffers org-agenda-new-buffers) |
| 3323 | (setq org-agenda-new-buffers nil) | 3404 | (setq org-agenda-new-buffers nil) |
| 3324 | (org-agenda-quit arg)) | 3405 | (org-agenda-quit)) |
| 3325 | 3406 | ||
| 3326 | (defun org-agenda-redo (&optional arg) | 3407 | (defun org-agenda-redo () |
| 3327 | "Rebuild Agenda" | 3408 | "Rebuild Agenda." |
| 3328 | (interactive "P") | 3409 | (interactive) |
| 3329 | (eval org-agenda-redo-command)) | 3410 | (eval org-agenda-redo-command)) |
| 3330 | 3411 | ||
| 3331 | (defun org-agenda-goto-today (arg) | 3412 | (defun org-agenda-goto-today () |
| 3332 | "Go to today." | 3413 | "Go to today." |
| 3333 | (interactive "P") | 3414 | (interactive) |
| 3334 | (if (boundp 'starting-day) | 3415 | (if (boundp 'starting-day) |
| 3335 | (let ((cmd (car org-agenda-redo-command)) | 3416 | (let ((cmd (car org-agenda-redo-command)) |
| 3336 | (iall (nth 1 org-agenda-redo-command)) | 3417 | (iall (nth 1 org-agenda-redo-command)) |
| @@ -3357,17 +3438,9 @@ With prefix ARG, go back that many times `org-agenda-ndays'." | |||
| 3357 | (org-agenda (if (boundp 'include-all-loc) include-all-loc nil) | 3438 | (org-agenda (if (boundp 'include-all-loc) include-all-loc nil) |
| 3358 | (- starting-day (* arg org-agenda-ndays)))) | 3439 | (- starting-day (* arg org-agenda-ndays)))) |
| 3359 | 3440 | ||
| 3360 | (defun org-agenda-day-view (arg) | 3441 | (defun org-agenda-toggle-week-view () |
| 3361 | "Switch agenda to single day view." | 3442 | "Toggle weekly/daily view for aagenda." |
| 3362 | (interactive "P") | 3443 | (interactive) |
| 3363 | (unless (boundp 'starting-day) | ||
| 3364 | (error "Not allowed")) | ||
| 3365 | (setq org-agenda-ndays 1) | ||
| 3366 | (org-agenda include-all-loc starting-day 1)) | ||
| 3367 | |||
| 3368 | (defun org-agenda-week-view (arg) | ||
| 3369 | "Switch agenda to week view." | ||
| 3370 | (interactive "P") | ||
| 3371 | (unless (boundp 'starting-day) | 3444 | (unless (boundp 'starting-day) |
| 3372 | (error "Not allowed")) | 3445 | (error "Not allowed")) |
| 3373 | (setq org-agenda-ndays | 3446 | (setq org-agenda-ndays |
| @@ -3397,6 +3470,21 @@ With prefix ARG, go back that many times `org-agenda-ndays'." | |||
| 3397 | (if (not (re-search-backward "^\\S-" nil t arg)) | 3470 | (if (not (re-search-backward "^\\S-" nil t arg)) |
| 3398 | (error "No previous date before this line in this buffer."))) | 3471 | (error "No previous date before this line in this buffer."))) |
| 3399 | 3472 | ||
| 3473 | ;; Initialize the highlight | ||
| 3474 | (defvar org-hl (funcall (if org-xemacs-p 'make-extent 'make-overlay) 1 1)) | ||
| 3475 | (funcall (if org-xemacs-p 'set-extent-property 'overlay-put) org-hl | ||
| 3476 | 'face 'highlight) | ||
| 3477 | |||
| 3478 | (defun org-highlight (begin end &optional buffer) | ||
| 3479 | "Highlight a region with overlay." | ||
| 3480 | (funcall (if org-xemacs-p 'set-extent-endpoints 'move-overlay) | ||
| 3481 | org-hl begin end (or buffer (current-buffer)))) | ||
| 3482 | |||
| 3483 | (defun org-unhighlight () | ||
| 3484 | "Detach overlay INDEX." | ||
| 3485 | (funcall (if org-xemacs-p 'detach-extent 'delete-overlay) org-hl)) | ||
| 3486 | |||
| 3487 | |||
| 3400 | (defun org-agenda-follow-mode () | 3488 | (defun org-agenda-follow-mode () |
| 3401 | "Toggle follow mode in an agenda buffer." | 3489 | "Toggle follow mode in an agenda buffer." |
| 3402 | (interactive) | 3490 | (interactive) |
| @@ -3430,21 +3518,22 @@ With prefix ARG, go back that many times `org-agenda-ndays'." | |||
| 3430 | (get-text-property (point) 'org-marker)) | 3518 | (get-text-property (point) 'org-marker)) |
| 3431 | (org-agenda-show))) | 3519 | (org-agenda-show))) |
| 3432 | 3520 | ||
| 3521 | (defvar org-disable-diary nil) ;Dynamically-scoped param. | ||
| 3522 | |||
| 3433 | (defun org-get-entries-from-diary (date) | 3523 | (defun org-get-entries-from-diary (date) |
| 3434 | "Get the (emacs calendar) diary entries for DATE." | 3524 | "Get the (Emacs Calendar) diary entries for DATE." |
| 3435 | (let* ((fancy-diary-buffer "*temporary-fancy-diary-buffer*") | 3525 | (let* ((fancy-diary-buffer "*temporary-fancy-diary-buffer*") |
| 3436 | (diary-display-hook '(fancy-diary-display)) | 3526 | (diary-display-hook '(fancy-diary-display)) |
| 3437 | (list-diary-entries-hook | 3527 | (list-diary-entries-hook |
| 3438 | (cons 'org-diary-default-entry list-diary-entries-hook)) | 3528 | (cons 'org-diary-default-entry list-diary-entries-hook)) |
| 3439 | entries | 3529 | entries tod tods |
| 3440 | (disable-org-diary t)) | 3530 | (org-disable-diary t)) |
| 3441 | (save-excursion | 3531 | (save-excursion |
| 3442 | (save-window-excursion | 3532 | (save-window-excursion |
| 3443 | (list-diary-entries date 1))) | 3533 | (list-diary-entries date 1))) |
| 3444 | (if (not (get-buffer fancy-diary-buffer)) | 3534 | (if (not (get-buffer fancy-diary-buffer)) |
| 3445 | (setq entries nil) | 3535 | (setq entries nil) |
| 3446 | (save-excursion | 3536 | (with-current-buffer fancy-diary-buffer |
| 3447 | (switch-to-buffer fancy-diary-buffer) | ||
| 3448 | (setq buffer-read-only nil) | 3537 | (setq buffer-read-only nil) |
| 3449 | (if (= (point-max) 1) | 3538 | (if (= (point-max) 1) |
| 3450 | ;; No entries | 3539 | ;; No entries |
| @@ -3452,11 +3541,6 @@ With prefix ARG, go back that many times `org-agenda-ndays'." | |||
| 3452 | ;; Omit the date and other unnecessary stuff | 3541 | ;; Omit the date and other unnecessary stuff |
| 3453 | (org-agenda-cleanup-fancy-diary) | 3542 | (org-agenda-cleanup-fancy-diary) |
| 3454 | ;; Add prefix to each line and extend the text properties | 3543 | ;; Add prefix to each line and extend the text properties |
| 3455 | (goto-char (point-min)) | ||
| 3456 | (while (and (re-search-forward "^" nil t) (not (eobp))) | ||
| 3457 | (replace-match " Diary: ") | ||
| 3458 | (add-text-properties (point-at-bol) (point) | ||
| 3459 | (text-properties-at (point)))) | ||
| 3460 | (if (= (point-max) 1) | 3544 | (if (= (point-max) 1) |
| 3461 | (setq entries nil) | 3545 | (setq entries nil) |
| 3462 | (setq entries (buffer-substring (point-min) (- (point-max) 1))))) | 3546 | (setq entries (buffer-substring (point-min) (- (point-max) 1))))) |
| @@ -3467,31 +3551,33 @@ With prefix ARG, go back that many times `org-agenda-ndays'." | |||
| 3467 | (setq entries | 3551 | (setq entries |
| 3468 | (mapcar | 3552 | (mapcar |
| 3469 | (lambda (x) | 3553 | (lambda (x) |
| 3470 | (if (string-match "\\<\\([012][0-9]\\):\\([0-6][0-9]\\)" x) | 3554 | (setq x (org-format-agenda-item "" x "Diary")) |
| 3471 | (add-text-properties | 3555 | ;; Extend the text properties to the beginning of the line |
| 3472 | 1 (length x) | 3556 | (add-text-properties |
| 3473 | (list 'time-of-day | 3557 | 0 (length x) |
| 3474 | (+ (* 100 (string-to-number | 3558 | (text-properties-at (1- (length x)) x) |
| 3475 | (match-string 1 x))) | 3559 | x) |
| 3476 | (string-to-number (match-string 2 x)))) | ||
| 3477 | x)) | ||
| 3478 | x) | 3560 | x) |
| 3479 | entries))))) | 3561 | entries))))) |
| 3480 | 3562 | ||
| 3481 | (defun org-agenda-cleanup-fancy-diary () | 3563 | (defun org-agenda-cleanup-fancy-diary () |
| 3482 | "Remove unwanted stuff in buffer created by fancy-diary-display. | 3564 | "Remove unwanted stuff in buffer created by fancy-diary-display. |
| 3483 | This gets rid of the date, the underline under the date, and | 3565 | This gets rid of the date, the underline under the date, and |
| 3484 | the dummy entry installed by org-mode to ensure non-empty diary for each | 3566 | the dummy entry installed by `org-mode' to ensure non-empty diary for each |
| 3485 | date." | 3567 | date. Itt also removes lines that contain only whitespace." |
| 3486 | (goto-char (point-min)) | 3568 | (goto-char (point-min)) |
| 3487 | (if (looking-at ".*?:[ \t]*") | 3569 | (if (looking-at ".*?:[ \t]*") |
| 3488 | (progn | 3570 | (progn |
| 3489 | (replace-match "") | 3571 | (replace-match "") |
| 3490 | (re-search-forward "\n=+$" nil t) | 3572 | (re-search-forward "\n=+$" nil t) |
| 3491 | (replace-match "") | 3573 | (replace-match "") |
| 3492 | (while (re-search-backward "^ +" nil t) (replace-match ""))) | 3574 | (while (re-search-backward "^ +\n?" nil t) (replace-match ""))) |
| 3493 | (re-search-forward "\n=+$" nil t) | 3575 | (re-search-forward "\n=+$" nil t) |
| 3494 | (delete-region (point-min) (min (point-max) (1+ (match-end 0))))) | 3576 | (delete-region (point-min) (min (point-max) (1+ (match-end 0))))) |
| 3577 | (goto-char (point-min)) | ||
| 3578 | (while (re-search-forward "^ +\n" nil t) | ||
| 3579 | (replace-match "")) | ||
| 3580 | (goto-char (point-min)) | ||
| 3495 | (if (re-search-forward "^Org-mode dummy\n?" nil t) | 3581 | (if (re-search-forward "^Org-mode dummy\n?" nil t) |
| 3496 | (replace-match ""))) | 3582 | (replace-match ""))) |
| 3497 | 3583 | ||
| @@ -3501,7 +3587,7 @@ date." | |||
| 3501 | (eval-after-load "diary-lib" | 3587 | (eval-after-load "diary-lib" |
| 3502 | '(defadvice add-to-diary-list (before org-mark-diary-entry activate) | 3588 | '(defadvice add-to-diary-list (before org-mark-diary-entry activate) |
| 3503 | "Make the position visible." | 3589 | "Make the position visible." |
| 3504 | (if (and (boundp 'disable-org-diary) ;; called from org-agenda | 3590 | (if (and org-disable-diary ;; called from org-agenda |
| 3505 | (stringp string) | 3591 | (stringp string) |
| 3506 | (buffer-file-name)) | 3592 | (buffer-file-name)) |
| 3507 | (add-text-properties | 3593 | (add-text-properties |
| @@ -3606,7 +3692,7 @@ sure that TODAY is included in the list." | |||
| 3606 | 3692 | ||
| 3607 | ;;;###autoload | 3693 | ;;;###autoload |
| 3608 | (defun org-diary (&rest args) | 3694 | (defun org-diary (&rest args) |
| 3609 | "Returns diary information from org-files. | 3695 | "Return diary information from org-files. |
| 3610 | This function can be used in a \"sexp\" diary entry in the Emacs calendar. | 3696 | This function can be used in a \"sexp\" diary entry in the Emacs calendar. |
| 3611 | It accesses org files and extracts information from those files to be | 3697 | It accesses org files and extracts information from those files to be |
| 3612 | listed in the diary. The function accepts arguments specifying what | 3698 | listed in the diary. The function accepts arguments specifying what |
| @@ -3649,6 +3735,7 @@ The function expects the lisp variables `entry' and `date' to be provided | |||
| 3649 | by the caller, because this is how the calendar works. Don't use this | 3735 | by the caller, because this is how the calendar works. Don't use this |
| 3650 | function from a program - use `org-agenda-get-day-entries' instead." | 3736 | function from a program - use `org-agenda-get-day-entries' instead." |
| 3651 | (org-agenda-maybe-reset-markers) | 3737 | (org-agenda-maybe-reset-markers) |
| 3738 | (org-compile-agenda-prefix-format org-agenda-prefix-format) | ||
| 3652 | (setq args (or args '(:deadline :scheduled :timestamp))) | 3739 | (setq args (or args '(:deadline :scheduled :timestamp))) |
| 3653 | (let* ((files (if (and entry (stringp entry) (string-match "\\S-" entry)) | 3740 | (let* ((files (if (and entry (stringp entry) (string-match "\\S-" entry)) |
| 3654 | (list entry) | 3741 | (list entry) |
| @@ -3656,14 +3743,14 @@ function from a program - use `org-agenda-get-day-entries' instead." | |||
| 3656 | file rtn results) | 3743 | file rtn results) |
| 3657 | ;; If this is called during org-agenda, don't return any entries to | 3744 | ;; If this is called during org-agenda, don't return any entries to |
| 3658 | ;; the calendar. Org Agenda will list these entries itself. | 3745 | ;; the calendar. Org Agenda will list these entries itself. |
| 3659 | (if (boundp 'disable-org-diary) (setq files nil)) | 3746 | (if org-disable-diary (setq files nil)) |
| 3660 | (while (setq file (pop files)) | 3747 | (while (setq file (pop files)) |
| 3661 | (setq rtn (apply 'org-agenda-get-day-entries file date args)) | 3748 | (setq rtn (apply 'org-agenda-get-day-entries file date args)) |
| 3662 | (setq results (append results rtn))) | 3749 | (setq results (append results rtn))) |
| 3663 | (concat (org-finalize-agenda-entries results) "\n"))) | 3750 | (concat (org-finalize-agenda-entries results) "\n"))) |
| 3664 | 3751 | ||
| 3665 | (defun org-agenda-get-day-entries (file date &rest args) | 3752 | (defun org-agenda-get-day-entries (file date &rest args) |
| 3666 | "Does the work for `org-diary' and `org-agenda' | 3753 | "Does the work for `org-diary' and `org-agenda'. |
| 3667 | FILE is the path to a file to be checked for entries. DATE is date like | 3754 | FILE is the path to a file to be checked for entries. DATE is date like |
| 3668 | the one returned by `calendar-current-date'. ARGS are symbols indicating | 3755 | the one returned by `calendar-current-date'. ARGS are symbols indicating |
| 3669 | which kind of entries should be extracted. For details about these, see | 3756 | which kind of entries should be extracted. For details about these, see |
| @@ -3672,26 +3759,26 @@ the documentation of `org-diary'." | |||
| 3672 | (let* ((org-startup-with-deadline-check nil) | 3759 | (let* ((org-startup-with-deadline-check nil) |
| 3673 | (org-startup-folded nil) | 3760 | (org-startup-folded nil) |
| 3674 | (buffer (if (file-exists-p file) | 3761 | (buffer (if (file-exists-p file) |
| 3675 | ; (find-file-noselect file) | ||
| 3676 | (org-get-agenda-file-buffer file) | 3762 | (org-get-agenda-file-buffer file) |
| 3677 | (error "No such file %s" file))) | 3763 | (error "No such file %s" file))) |
| 3678 | (respect-narrow-p (boundp 'org-respect-restriction)) | ||
| 3679 | arg results rtn) | 3764 | arg results rtn) |
| 3680 | (if (not buffer) | 3765 | (if (not buffer) |
| 3681 | ;; If file does not exist, make sure an error message ends up in diary | 3766 | ;; If file does not exist, make sure an error message ends up in diary |
| 3682 | (format "ORG-AGENDA-ERROR: No such org-file %s" file) | 3767 | (format "ORG-AGENDA-ERROR: No such org-file %s" file) |
| 3683 | (save-excursion | 3768 | (with-current-buffer buffer |
| 3684 | (set-buffer buffer) | 3769 | (unless (eq major-mode 'org-mode) |
| 3770 | (error "Agenda file %s is not in `org-mode'" file)) | ||
| 3685 | (let ((case-fold-search nil)) | 3771 | (let ((case-fold-search nil)) |
| 3686 | (save-excursion | 3772 | (save-excursion |
| 3687 | (save-restriction | 3773 | (save-restriction |
| 3688 | (if respect-narrow-p | 3774 | (if org-respect-restriction |
| 3689 | (if (org-region-active-p) | 3775 | (if (org-region-active-p) |
| 3690 | ;; Respect a region to restrict search | 3776 | ;; Respect a region to restrict search |
| 3691 | (narrow-to-region (region-beginning) (region-end))) | 3777 | (narrow-to-region (region-beginning) (region-end))) |
| 3692 | ;; If we work for the calendar or many files, | 3778 | ;; If we work for the calendar or many files, |
| 3693 | ;; get rid of any restriction | 3779 | ;; get rid of any restriction |
| 3694 | (widen)) | 3780 | (widen)) |
| 3781 | ;; The way we repeatedly append to `results' makes it O(n^2) :-( | ||
| 3695 | (while (setq arg (pop args)) | 3782 | (while (setq arg (pop args)) |
| 3696 | (cond | 3783 | (cond |
| 3697 | ((and (eq arg :todo) | 3784 | ((and (eq arg :todo) |
| @@ -3748,7 +3835,7 @@ the documentation of `org-diary'." | |||
| 3748 | (regexp (concat "[\n\r]\\*+ *\\(" org-not-done-regexp | 3835 | (regexp (concat "[\n\r]\\*+ *\\(" org-not-done-regexp |
| 3749 | "[^\n\r]*\\)")) | 3836 | "[^\n\r]*\\)")) |
| 3750 | marker priority | 3837 | marker priority |
| 3751 | ee txt pl) | 3838 | ee txt) |
| 3752 | (goto-char (point-min)) | 3839 | (goto-char (point-min)) |
| 3753 | (while (re-search-forward regexp nil t) | 3840 | (while (re-search-forward regexp nil t) |
| 3754 | (goto-char (match-beginning 1)) | 3841 | (goto-char (match-beginning 1)) |
| @@ -3855,7 +3942,7 @@ the documentation of `org-diary'." | |||
| 3855 | (todayp (equal date (calendar-current-date))) ; DATE bound by calendar | 3942 | (todayp (equal date (calendar-current-date))) ; DATE bound by calendar |
| 3856 | (d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar | 3943 | (d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar |
| 3857 | d2 diff pos pos1 | 3944 | d2 diff pos pos1 |
| 3858 | ee txt head hdmarker) | 3945 | ee txt head) |
| 3859 | (goto-char (point-min)) | 3946 | (goto-char (point-min)) |
| 3860 | (while (re-search-forward regexp nil t) | 3947 | (while (re-search-forward regexp nil t) |
| 3861 | (setq pos (1- (match-beginning 1)) | 3948 | (setq pos (1- (match-beginning 1)) |
| @@ -3913,7 +4000,7 @@ the documentation of `org-diary'." | |||
| 3913 | (regexp org-scheduled-time-regexp) | 4000 | (regexp org-scheduled-time-regexp) |
| 3914 | (todayp (equal date (calendar-current-date))) ; DATE bound by calendar | 4001 | (todayp (equal date (calendar-current-date))) ; DATE bound by calendar |
| 3915 | (d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar | 4002 | (d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar |
| 3916 | d2 diff marker hdmarker pos pos1 | 4003 | d2 diff pos pos1 |
| 3917 | ee txt head) | 4004 | ee txt head) |
| 3918 | (goto-char (point-min)) | 4005 | (goto-char (point-min)) |
| 3919 | (while (re-search-forward regexp nil t) | 4006 | (while (re-search-forward regexp nil t) |
| @@ -3990,38 +4077,66 @@ the documentation of `org-diary'." | |||
| 3990 | ;; Sort the entries by expiration date. | 4077 | ;; Sort the entries by expiration date. |
| 3991 | (nreverse ee))) | 4078 | (nreverse ee))) |
| 3992 | 4079 | ||
| 3993 | 4080 | (defun org-format-agenda-item (prefix txt &optional category) | |
| 3994 | (defun org-format-agenda-item (prefix txt) | ||
| 3995 | "Format TXT to be inserted into the agenda buffer. | 4081 | "Format TXT to be inserted into the agenda buffer. |
| 3996 | In particular, this indents the line and adds a category." | 4082 | In particular, this indents the line and adds a category." |
| 3997 | (let ((cat (or org-category | 4083 | (let* ((category (or category |
| 3998 | (file-name-sans-extension | 4084 | org-category |
| 3999 | (file-name-nondirectory (buffer-file-name))))) | 4085 | (file-name-sans-extension |
| 4000 | time rtn) | 4086 | (file-name-nondirectory (buffer-file-name))))) |
| 4001 | (if (symbolp cat) (setq cat (symbol-name cat))) | 4087 | (extra prefix) |
| 4002 | (setq rtn (format " %-10s %s%s" (concat cat ":") prefix txt)) | 4088 | (time-of-day (org-get-time-of-day txt)) |
| 4003 | (add-text-properties | 4089 | (t1 (if time-of-day (concat "0" (int-to-string time-of-day)) "0000")) |
| 4004 | 0 2 (list 'category (downcase cat) | 4090 | (time (if time-of-day |
| 4005 | 'prefix-length (- (length rtn) (length txt)) | 4091 | (concat (substring t1 -4 -2) |
| 4006 | 'time-of-day (org-get-time-of-day rtn)) | 4092 | ":" (substring t1 -2)) |
| 4093 | "")) | ||
| 4094 | rtn) | ||
| 4095 | (if (symbolp category) (setq category (symbol-name category))) | ||
| 4096 | (setq rtn (concat (eval org-prefix-format-compiled) txt)) | ||
| 4097 | (add-text-properties | ||
| 4098 | 0 (length rtn) (list 'category (downcase category) | ||
| 4099 | 'prefix-length (- (length rtn) (length txt)) | ||
| 4100 | 'time-of-day time-of-day) | ||
| 4007 | rtn) | 4101 | rtn) |
| 4008 | rtn)) | 4102 | rtn)) |
| 4009 | 4103 | ||
| 4010 | ;; FIXME: Should this be restricted to beginning of string? | 4104 | (defun org-compile-prefix-format (format) |
| 4105 | "Compile the prefix format into a Lisp form that can be evaluated. | ||
| 4106 | The resulting form is returned and stored in the variable | ||
| 4107 | `org-prefix-format-compiled'." | ||
| 4108 | (let ((start 0) varform vars (s format) c) | ||
| 4109 | (while (string-match "%\\([-+]?[0-9.]*\\)\\([ .;,:!?=|/<>]?\\)\\([cts]\\)" | ||
| 4110 | s start) | ||
| 4111 | (setq var (cdr (assoc (match-string 3 s) | ||
| 4112 | '(("c" . category) ("t" . time) ("s" . extra)))) | ||
| 4113 | c (match-string 2 s) | ||
| 4114 | start (1+ (match-beginning 0))) | ||
| 4115 | (if (= (length c) 1) | ||
| 4116 | (setq varform `(if (equal "" ,var) "" (concat ,var ,c))) | ||
| 4117 | (setq varform var)) | ||
| 4118 | (setq s (replace-match "%\\1s" t nil s)) | ||
| 4119 | (push varform vars)) | ||
| 4120 | (setq vars (nreverse vars)) | ||
| 4121 | (setq org-prefix-format-compiled `(format ,s ,@vars)))) | ||
| 4122 | |||
| 4011 | (defun org-get-time-of-day (s) | 4123 | (defun org-get-time-of-day (s) |
| 4012 | "Check string S for a time of day." | 4124 | "Check string S for a time of day. |
| 4125 | If found, return it as a military time number between 0 and 2400. | ||
| 4126 | If not found, return nil." | ||
| 4013 | (save-match-data | 4127 | (save-match-data |
| 4014 | (when (and | 4128 | (when (or |
| 4015 | (string-match | 4129 | (string-match |
| 4016 | "\\<\\([012][0-9]\\)\\(:\\([0-6][0-9]\\)\\)?\\([AaPp][Mm]\\)?\\>" s) | 4130 | "\\<\\([012]?[0-9]\\)\\(:\\([0-5][0-9]\\)\\)\\([AaPp][Mm]\\)?\\>" s) |
| 4017 | (or (match-beginning 2) (match-beginning 4))) | 4131 | (string-match |
| 4018 | (+ (* 100 (+ (string-to-number (match-string 1 s)) | 4132 | "\\<\\([012]?[0-9]\\)\\(:\\([0-5][0-9]\\)\\)?\\([AaPp][Mm]\\)\\>" s)) |
| 4019 | (if (and (match-beginning 4) | 4133 | (+ (* 100 (+ (string-to-number (match-string 1 s)) |
| 4020 | (equal (downcase (match-string 4 s)) "pm")) | 4134 | (if (and (match-beginning 4) |
| 4021 | 12 0))) | 4135 | (equal (downcase (match-string 4 s)) "pm")) |
| 4022 | (if (match-beginning 3) | 4136 | 12 0))) |
| 4023 | (string-to-number (match-string 3 s)) | 4137 | (if (match-beginning 3) |
| 4024 | 0))))) | 4138 | (string-to-number (match-string 3 s)) |
| 4139 | 0))))) | ||
| 4025 | 4140 | ||
| 4026 | (defun org-finalize-agenda-entries (list) | 4141 | (defun org-finalize-agenda-entries (list) |
| 4027 | "Sort and concatenate the agenda items." | 4142 | "Sort and concatenate the agenda items." |
| @@ -4073,7 +4188,7 @@ and by additional input from the age of a schedules or deadline entry." | |||
| 4073 | (let* ((pri (get-text-property (point-at-bol) 'priority))) | 4188 | (let* ((pri (get-text-property (point-at-bol) 'priority))) |
| 4074 | (message "Priority is %d" (if pri pri -1000)))) | 4189 | (message "Priority is %d" (if pri pri -1000)))) |
| 4075 | 4190 | ||
| 4076 | (defun org-agenda-goto () | 4191 | (defun org-agenda-goto (&optional highlight) |
| 4077 | "Go to the Org-mode file which contains the item at point." | 4192 | "Go to the Org-mode file which contains the item at point." |
| 4078 | (interactive) | 4193 | (interactive) |
| 4079 | (let* ((marker (or (get-text-property (point) 'org-marker) | 4194 | (let* ((marker (or (get-text-property (point) 'org-marker) |
| @@ -4087,7 +4202,8 @@ and by additional input from the age of a schedules or deadline entry." | |||
| 4087 | (org-show-hidden-entry) | 4202 | (org-show-hidden-entry) |
| 4088 | (save-excursion | 4203 | (save-excursion |
| 4089 | (and (outline-next-heading) | 4204 | (and (outline-next-heading) |
| 4090 | (org-flag-heading nil)))))) ; show the next heading | 4205 | (org-flag-heading nil)))) ; show the next heading |
| 4206 | (and highlight (org-highlight (point-at-bol) (point-at-eol))))) | ||
| 4091 | 4207 | ||
| 4092 | (defun org-agenda-switch-to () | 4208 | (defun org-agenda-switch-to () |
| 4093 | "Go to the Org-mode file which contains the item at point." | 4209 | "Go to the Org-mode file which contains the item at point." |
| @@ -4116,14 +4232,14 @@ and by additional input from the age of a schedules or deadline entry." | |||
| 4116 | "Display the Org-mode file which contains the item at point." | 4232 | "Display the Org-mode file which contains the item at point." |
| 4117 | (interactive) | 4233 | (interactive) |
| 4118 | (let ((win (selected-window))) | 4234 | (let ((win (selected-window))) |
| 4119 | (org-agenda-goto) | 4235 | (org-agenda-goto t) |
| 4120 | (select-window win))) | 4236 | (select-window win))) |
| 4121 | 4237 | ||
| 4122 | (defun org-agenda-recenter (arg) | 4238 | (defun org-agenda-recenter (arg) |
| 4123 | "Display the Org-mode file which contains the item at point and recenter." | 4239 | "Display the Org-mode file which contains the item at point and recenter." |
| 4124 | (interactive "P") | 4240 | (interactive "P") |
| 4125 | (let ((win (selected-window))) | 4241 | (let ((win (selected-window))) |
| 4126 | (org-agenda-goto) | 4242 | (org-agenda-goto t) |
| 4127 | (recenter arg) | 4243 | (recenter arg) |
| 4128 | (select-window win))) | 4244 | (select-window win))) |
| 4129 | 4245 | ||
| @@ -4159,8 +4275,7 @@ the same tree node, and the headline of the tree node in the Org-mode file." | |||
| 4159 | (hdmarker (get-text-property (point) 'org-hd-marker)) | 4275 | (hdmarker (get-text-property (point) 'org-hd-marker)) |
| 4160 | (buffer-read-only nil) | 4276 | (buffer-read-only nil) |
| 4161 | newhead) | 4277 | newhead) |
| 4162 | (save-excursion | 4278 | (with-current-buffer buffer |
| 4163 | (set-buffer buffer) | ||
| 4164 | (widen) | 4279 | (widen) |
| 4165 | (goto-char pos) | 4280 | (goto-char pos) |
| 4166 | (org-show-hidden-entry) | 4281 | (org-show-hidden-entry) |
| @@ -4225,18 +4340,14 @@ This changes the line at point, all other lines in the agenda referring to | |||
| 4225 | the same tree node, and the headline of the tree node in the Org-mode file." | 4340 | the same tree node, and the headline of the tree node in the Org-mode file." |
| 4226 | (interactive) | 4341 | (interactive) |
| 4227 | (org-agenda-check-no-diary) | 4342 | (org-agenda-check-no-diary) |
| 4228 | (let* ((props (text-properties-at (point))) | 4343 | (let* ((marker (or (get-text-property (point) 'org-marker) |
| 4229 | (col (current-column)) | ||
| 4230 | (marker (or (get-text-property (point) 'org-marker) | ||
| 4231 | (org-agenda-error))) | 4344 | (org-agenda-error))) |
| 4232 | (pl (get-text-property (point-at-bol) 'prefix-length)) | ||
| 4233 | (buffer (marker-buffer marker)) | 4345 | (buffer (marker-buffer marker)) |
| 4234 | (pos (marker-position marker)) | 4346 | (pos (marker-position marker)) |
| 4235 | (hdmarker (get-text-property (point) 'org-hd-marker)) | 4347 | (hdmarker (get-text-property (point) 'org-hd-marker)) |
| 4236 | (buffer-read-only nil) | 4348 | (buffer-read-only nil) |
| 4237 | newhead) | 4349 | newhead) |
| 4238 | (save-excursion | 4350 | (with-current-buffer buffer |
| 4239 | (set-buffer buffer) | ||
| 4240 | (widen) | 4351 | (widen) |
| 4241 | (goto-char pos) | 4352 | (goto-char pos) |
| 4242 | (org-show-hidden-entry) | 4353 | (org-show-hidden-entry) |
| @@ -4271,20 +4382,21 @@ the same tree node, and the headline of the tree node in the Org-mode file." | |||
| 4271 | (org-agenda-date-later (- arg) what)) | 4382 | (org-agenda-date-later (- arg) what)) |
| 4272 | 4383 | ||
| 4273 | (defun org-agenda-date-prompt (arg) | 4384 | (defun org-agenda-date-prompt (arg) |
| 4274 | "Change the date of this item. Date is prompted for, with default today." | 4385 | "Change the date of this item. Date is prompted for, with default today. |
| 4275 | (interactive "p") | 4386 | The prefix ARG is passed to the `org-time-stamp' command and can therefore |
| 4387 | be used to request time specification in the time stamp." | ||
| 4388 | (interactive "P") | ||
| 4276 | (org-agenda-check-no-diary) | 4389 | (org-agenda-check-no-diary) |
| 4277 | (let* ((marker (or (get-text-property (point) 'org-marker) | 4390 | (let* ((marker (or (get-text-property (point) 'org-marker) |
| 4278 | (org-agenda-error))) | 4391 | (org-agenda-error))) |
| 4279 | (buffer (marker-buffer marker)) | 4392 | (buffer (marker-buffer marker)) |
| 4280 | (pos (marker-position marker))) | 4393 | (pos (marker-position marker))) |
| 4281 | (save-excursion | 4394 | (with-current-buffer buffer |
| 4282 | (set-buffer buffer) | ||
| 4283 | (widen) | 4395 | (widen) |
| 4284 | (goto-char pos) | 4396 | (goto-char pos) |
| 4285 | (if (not (org-at-timestamp-p)) | 4397 | (if (not (org-at-timestamp-p)) |
| 4286 | (error "Cannot find time stamp")) | 4398 | (error "Cannot find time stamp")) |
| 4287 | (org-time-stamp nil) | 4399 | (org-time-stamp arg) |
| 4288 | (message "Time stamp changed to %s" org-last-changed-timestamp)))) | 4400 | (message "Time stamp changed to %s" org-last-changed-timestamp)))) |
| 4289 | 4401 | ||
| 4290 | (defun org-get-heading () | 4402 | (defun org-get-heading () |
| @@ -4295,10 +4407,10 @@ the same tree node, and the headline of the tree node in the Org-mode file." | |||
| 4295 | (match-string 1) | 4407 | (match-string 1) |
| 4296 | ""))) | 4408 | ""))) |
| 4297 | 4409 | ||
| 4298 | (defun org-agenda-diary-entry (arg) | 4410 | (defun org-agenda-diary-entry () |
| 4299 | "Make a diary entry, like the `i' command from the calendar. | 4411 | "Make a diary entry, like the `i' command from the calendar. |
| 4300 | All the standard commands work: block, weekly etc" | 4412 | All the standard commands work: block, weekly etc" |
| 4301 | (interactive "P") | 4413 | (interactive) |
| 4302 | (require 'diary-lib) | 4414 | (require 'diary-lib) |
| 4303 | (let* ((char (progn | 4415 | (let* ((char (progn |
| 4304 | (message "Diary entry: [d]ay [w]eekly [m]onthly [y]early [a]nniversary [b]lock [c]yclic") | 4416 | (message "Diary entry: [d]ay [w]eekly [m]onthly [y]early [a]nniversary [b]lock [c]yclic") |
| @@ -4344,7 +4456,6 @@ the cursor position." | |||
| 4344 | (error "Don't know which date to use for calendar command")) | 4456 | (error "Don't know which date to use for calendar command")) |
| 4345 | (let* ((oldf (symbol-function 'calendar-cursor-to-date)) | 4457 | (let* ((oldf (symbol-function 'calendar-cursor-to-date)) |
| 4346 | (point (point)) | 4458 | (point (point)) |
| 4347 | (mark (or (mark t) (point))) | ||
| 4348 | (date (calendar-gregorian-from-absolute | 4459 | (date (calendar-gregorian-from-absolute |
| 4349 | (get-text-property point 'day))) | 4460 | (get-text-property point 'day))) |
| 4350 | (displayed-day (extract-calendar-day date)) | 4461 | (displayed-day (extract-calendar-day date)) |
| @@ -4527,11 +4638,25 @@ optional argument IN-EMACS is non-nil, Emacs will visit the file." | |||
| 4527 | (defun org-follow-bbdb-link (name) | 4638 | (defun org-follow-bbdb-link (name) |
| 4528 | "Follow a BBDB link to NAME." | 4639 | "Follow a BBDB link to NAME." |
| 4529 | (require 'bbdb) | 4640 | (require 'bbdb) |
| 4530 | ;; First try an exact match | 4641 | (let ((inhibit-redisplay t)) |
| 4531 | (bbdb-name (concat "\\`" name "\\'") nil) | 4642 | (catch 'exit |
| 4532 | (if (= 0 (buffer-size (get-buffer "*BBDB*"))) | 4643 | ;; Exact match on name |
| 4533 | ;; No exact match - try partial match | 4644 | (bbdb-name (concat "\\`" name "\\'") nil) |
| 4534 | (bbdb-name name nil))) | 4645 | (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil)) |
| 4646 | ;; Exact match on name | ||
| 4647 | (bbdb-company (concat "\\`" name "\\'") nil) | ||
| 4648 | (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil)) | ||
| 4649 | ;; Partial match on name | ||
| 4650 | (bbdb-name name nil) | ||
| 4651 | (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil)) | ||
| 4652 | ;; Partial match on company | ||
| 4653 | (bbdb-company name nil) | ||
| 4654 | (if (< 0 (buffer-size (get-buffer "*BBDB*"))) (throw 'exit nil)) | ||
| 4655 | ;; General match including network address and notes | ||
| 4656 | (bbdb name nil) | ||
| 4657 | (when (= 0 (buffer-size (get-buffer "*BBDB*"))) | ||
| 4658 | (delete-window (get-buffer-window "*BBDB*")) | ||
| 4659 | (error "No matching BBDB record"))))) | ||
| 4535 | 4660 | ||
| 4536 | (defun org-follow-gnus-link (&optional group article) | 4661 | (defun org-follow-gnus-link (&optional group article) |
| 4537 | "Follow a Gnus link to GROUP and ARTICLE." | 4662 | "Follow a Gnus link to GROUP and ARTICLE." |
| @@ -4545,7 +4670,6 @@ optional argument IN-EMACS is non-nil, Emacs will visit the file." | |||
| 4545 | (gnus-summary-insert-cached-articles) | 4670 | (gnus-summary-insert-cached-articles) |
| 4546 | (gnus-summary-goto-article article nil 'force)) | 4671 | (gnus-summary-goto-article article nil 'force)) |
| 4547 | (message "Message could not be found."))))) | 4672 | (message "Message could not be found."))))) |
| 4548 | ;; (if article (gnus-summary-goto-article article nil 'force))) | ||
| 4549 | 4673 | ||
| 4550 | (defun org-follow-vm-link (&optional folder article readonly) | 4674 | (defun org-follow-vm-link (&optional folder article readonly) |
| 4551 | "Follow a VM link to FOLDER and ARTICLE." | 4675 | "Follow a VM link to FOLDER and ARTICLE." |
| @@ -4681,8 +4805,9 @@ For file links, arg negates `org-line-numbers-in-file-links'." | |||
| 4681 | 4805 | ||
| 4682 | ((eq major-mode 'bbdb-mode) | 4806 | ((eq major-mode 'bbdb-mode) |
| 4683 | (setq link (concat "bbdb:" | 4807 | (setq link (concat "bbdb:" |
| 4684 | (bbdb-record-name (bbdb-current-record))))) | 4808 | (or (bbdb-record-name (bbdb-current-record)) |
| 4685 | 4809 | (bbdb-record-company (bbdb-current-record)))))) | |
| 4810 | |||
| 4686 | ((eq major-mode 'calendar-mode) | 4811 | ((eq major-mode 'calendar-mode) |
| 4687 | (let ((cd (calendar-cursor-to-date))) | 4812 | (let ((cd (calendar-cursor-to-date))) |
| 4688 | (setq link | 4813 | (setq link |
| @@ -4702,7 +4827,6 @@ For file links, arg negates `org-line-numbers-in-file-links'." | |||
| 4702 | (folder (buffer-file-name)) | 4827 | (folder (buffer-file-name)) |
| 4703 | (subject (vm-su-subject message)) | 4828 | (subject (vm-su-subject message)) |
| 4704 | (author (vm-su-full-name message)) | 4829 | (author (vm-su-full-name message)) |
| 4705 | (address (vm-su-from message)) | ||
| 4706 | (message-id (vm-su-message-id message))) | 4830 | (message-id (vm-su-message-id message))) |
| 4707 | (setq folder (abbreviate-file-name folder)) | 4831 | (setq folder (abbreviate-file-name folder)) |
| 4708 | (if (string-match (concat "^" (regexp-quote vm-folder-directory)) | 4832 | (if (string-match (concat "^" (regexp-quote vm-folder-directory)) |
| @@ -4747,9 +4871,8 @@ For file links, arg negates `org-line-numbers-in-file-links'." | |||
| 4747 | group)) | 4871 | group)) |
| 4748 | (setq link (concat "gnus:" group))))) | 4872 | (setq link (concat "gnus:" group))))) |
| 4749 | 4873 | ||
| 4750 | ((or (eq major-mode 'gnus-summary-mode) | 4874 | ((memq major-mode '(gnus-summary-mode gnus-article-mode)) |
| 4751 | (eq major-mode 'gnus-article-mode)) | 4875 | (and (eq major-mode 'gnus-article-mode) (gnus-article-show-summary)) |
| 4752 | (gnus-article-show-summary) | ||
| 4753 | (gnus-summary-beginning-of-article) | 4876 | (gnus-summary-beginning-of-article) |
| 4754 | (let* ((group (car gnus-article-current)) | 4877 | (let* ((group (car gnus-article-current)) |
| 4755 | (article (cdr gnus-article-current)) | 4878 | (article (cdr gnus-article-current)) |
| @@ -4825,8 +4948,7 @@ For file links, arg negates `org-line-numbers-in-file-links'." | |||
| 4825 | 4948 | ||
| 4826 | 4949 | ||
| 4827 | (defun org-fixup-message-id-for-http (s) | 4950 | (defun org-fixup-message-id-for-http (s) |
| 4828 | "Replace special characters in a message id, so that it can be used | 4951 | "Replace special characters in a message id, so it can be used in an http query." |
| 4829 | in an http query." | ||
| 4830 | (while (string-match "<" s) | 4952 | (while (string-match "<" s) |
| 4831 | (setq s (replace-match "%3C" t t s))) | 4953 | (setq s (replace-match "%3C" t t s))) |
| 4832 | (while (string-match ">" s) | 4954 | (while (string-match ">" s) |
| @@ -4843,13 +4965,13 @@ Completion can be used to select a link previously stored with | |||
| 4843 | press RET at the prompt), the link defaults to the most recently | 4965 | press RET at the prompt), the link defaults to the most recently |
| 4844 | stored link. | 4966 | stored link. |
| 4845 | 4967 | ||
| 4846 | With a C-u prefix, prompts for a file to link to. The file name can be | 4968 | With a \\[universal-argument] prefix, prompts for a file to link to. The file name can be |
| 4847 | selected using completion. The path to the file will be relative to | 4969 | selected using completion. The path to the file will be relative to |
| 4848 | the current directory if the file is in the current directory or a | 4970 | the current directory if the file is in the current directory or a |
| 4849 | subdirectory. Otherwise, the link will be the absolute path as | 4971 | subdirectory. Otherwise, the link will be the absolute path as |
| 4850 | completed in the minibuffer (i.e. normally ~/path/to/file). | 4972 | completed in the minibuffer (i.e. normally ~/path/to/file). |
| 4851 | 4973 | ||
| 4852 | With two C-u prefixes, enforce an absolute path even if the file | 4974 | With two \\[universal-argument] prefixes, enforce an absolute path even if the file |
| 4853 | is in the current directory or below." | 4975 | is in the current directory or below." |
| 4854 | (interactive "P") | 4976 | (interactive "P") |
| 4855 | (let ((link (if complete-file | 4977 | (let ((link (if complete-file |
| @@ -4970,11 +5092,10 @@ See also the variable `org-reverse-note-order'." | |||
| 4970 | ;; Find the file | 5092 | ;; Find the file |
| 4971 | (if (not visiting) | 5093 | (if (not visiting) |
| 4972 | (find-file-noselect file)) | 5094 | (find-file-noselect file)) |
| 4973 | (save-excursion | 5095 | (with-current-buffer (get-file-buffer file) |
| 4974 | (set-buffer (get-file-buffer file)) | ||
| 4975 | (setq reversed (org-notes-order-reversed-p)) | 5096 | (setq reversed (org-notes-order-reversed-p)) |
| 4976 | (save-restriction | 5097 | (save-excursion |
| 4977 | (save-excursion | 5098 | (save-restriction |
| 4978 | (widen) | 5099 | (widen) |
| 4979 | ;; Ask the User for a location | 5100 | ;; Ask the User for a location |
| 4980 | (setq spos (if fastp 1 (org-get-location | 5101 | (setq spos (if fastp 1 (org-get-location |
| @@ -5038,12 +5159,6 @@ See also the variable `org-reverse-note-order'." | |||
| 5038 | ;; Emacs package. We call the former org-type tables, and the latter | 5159 | ;; Emacs package. We call the former org-type tables, and the latter |
| 5039 | ;; table.el-type tables. | 5160 | ;; table.el-type tables. |
| 5040 | 5161 | ||
| 5041 | ;; We use a before-change function to check if a table might need | ||
| 5042 | ;; an update. | ||
| 5043 | (defvar org-table-may-need-update t | ||
| 5044 | "Indicates of a table might need an update. | ||
| 5045 | This variable is set by `org-before-change-function'. `org-table-align' | ||
| 5046 | sets it back to nil.") | ||
| 5047 | 5162 | ||
| 5048 | (defun org-before-change-function (beg end) | 5163 | (defun org-before-change-function (beg end) |
| 5049 | "Every change indicates that a table might need an update." | 5164 | "Every change indicates that a table might need an update." |
| @@ -5058,7 +5173,7 @@ sets it back to nil.") | |||
| 5058 | (defconst org-table1-hline-regexp "^[ \t]*\\+-[-+]" | 5173 | (defconst org-table1-hline-regexp "^[ \t]*\\+-[-+]" |
| 5059 | "Detects a table-type table hline.") | 5174 | "Detects a table-type table hline.") |
| 5060 | (defconst org-table-any-line-regexp "^[ \t]*\\(|\\|\\+-[-+]\\)" | 5175 | (defconst org-table-any-line-regexp "^[ \t]*\\(|\\|\\+-[-+]\\)" |
| 5061 | "Detects an org-type or table-type table") | 5176 | "Detects an org-type or table-type table.") |
| 5062 | (defconst org-table-border-regexp "^[ \t]*[^| \t]" | 5177 | (defconst org-table-border-regexp "^[ \t]*[^| \t]" |
| 5063 | "Searching from within a table (any type) this finds the first line | 5178 | "Searching from within a table (any type) this finds the first line |
| 5064 | outside the table.") | 5179 | outside the table.") |
| @@ -5210,9 +5325,9 @@ This is being used to correctly align a single field after TAB or RET.") | |||
| 5210 | This is being used to correctly align a single field after TAB or RET.") | 5325 | This is being used to correctly align a single field after TAB or RET.") |
| 5211 | 5326 | ||
| 5212 | 5327 | ||
| 5213 | (defun org-table-align (&optional arg) | 5328 | (defun org-table-align () |
| 5214 | "Align the table at point by aligning all vertical bars." | 5329 | "Align the table at point by aligning all vertical bars." |
| 5215 | (interactive "P") | 5330 | (interactive) |
| 5216 | (let* ( | 5331 | (let* ( |
| 5217 | ;; Limits of table | 5332 | ;; Limits of table |
| 5218 | (beg (org-table-begin)) | 5333 | (beg (org-table-begin)) |
| @@ -5366,10 +5481,10 @@ With argument TABLE-TYPE, go to the end of a table.el-type table." | |||
| 5366 | (setq org-table-may-need-update t)) | 5481 | (setq org-table-may-need-update t)) |
| 5367 | (goto-char pos)))))) | 5482 | (goto-char pos)))))) |
| 5368 | 5483 | ||
| 5369 | (defun org-table-next-field (&optional arg) | 5484 | (defun org-table-next-field () |
| 5370 | "Go to the next field in the current table. | 5485 | "Go to the next field in the current table. |
| 5371 | Before doing so, re-align the table if necessary." | 5486 | Before doing so, re-align the table if necessary." |
| 5372 | (interactive "P") | 5487 | (interactive) |
| 5373 | (if (and org-table-automatic-realign | 5488 | (if (and org-table-automatic-realign |
| 5374 | org-table-may-need-update) | 5489 | org-table-may-need-update) |
| 5375 | (org-table-align)) | 5490 | (org-table-align)) |
| @@ -5388,10 +5503,10 @@ Before doing so, re-align the table if necessary." | |||
| 5388 | (error | 5503 | (error |
| 5389 | (org-table-insert-row 'below)))) | 5504 | (org-table-insert-row 'below)))) |
| 5390 | 5505 | ||
| 5391 | (defun org-table-previous-field (&optional arg) | 5506 | (defun org-table-previous-field () |
| 5392 | "Go to the previous field in the table. | 5507 | "Go to the previous field in the table. |
| 5393 | Before doing so, re-align the table if necessary." | 5508 | Before doing so, re-align the table if necessary." |
| 5394 | (interactive "P") | 5509 | (interactive) |
| 5395 | (if (and org-table-automatic-realign | 5510 | (if (and org-table-automatic-realign |
| 5396 | org-table-may-need-update) | 5511 | org-table-may-need-update) |
| 5397 | (org-table-align)) | 5512 | (org-table-align)) |
| @@ -5404,10 +5519,10 @@ Before doing so, re-align the table if necessary." | |||
| 5404 | (if (looking-at "| ?") | 5519 | (if (looking-at "| ?") |
| 5405 | (goto-char (match-end 0)))) | 5520 | (goto-char (match-end 0)))) |
| 5406 | 5521 | ||
| 5407 | (defun org-table-next-row (&optional arg) | 5522 | (defun org-table-next-row () |
| 5408 | "Go to the next row (same column) in the current table. | 5523 | "Go to the next row (same column) in the current table. |
| 5409 | Before doing so, re-align the table if necessary." | 5524 | Before doing so, re-align the table if necessary." |
| 5410 | (interactive "P") | 5525 | (interactive) |
| 5411 | (if (or (looking-at "[ \t]*$") | 5526 | (if (or (looking-at "[ \t]*$") |
| 5412 | (save-excursion (skip-chars-backward " \t") (bolp))) | 5527 | (save-excursion (skip-chars-backward " \t") (bolp))) |
| 5413 | (newline) | 5528 | (newline) |
| @@ -5470,6 +5585,9 @@ I.e. not on a hline or before the first or after the last column?" | |||
| 5470 | (looking-at "[ \t]*$")) | 5585 | (looking-at "[ \t]*$")) |
| 5471 | (error "Not in table data field"))) | 5586 | (error "Not in table data field"))) |
| 5472 | 5587 | ||
| 5588 | (defvar org-table-clip nil | ||
| 5589 | "Clipboard for table regions") | ||
| 5590 | |||
| 5473 | (defun org-table-blank-field () | 5591 | (defun org-table-blank-field () |
| 5474 | "Blank the current table field or active region." | 5592 | "Blank the current table field or active region." |
| 5475 | (interactive) | 5593 | (interactive) |
| @@ -5497,7 +5615,6 @@ is always the old value." | |||
| 5497 | (backward-char 1) | 5615 | (backward-char 1) |
| 5498 | (if (looking-at "|[^|\r\n]*") | 5616 | (if (looking-at "|[^|\r\n]*") |
| 5499 | (let* ((pos (match-beginning 0)) | 5617 | (let* ((pos (match-beginning 0)) |
| 5500 | (len (length (match-string 0))) | ||
| 5501 | (val (buffer-substring (1+ pos) (match-end 0)))) | 5618 | (val (buffer-substring (1+ pos) (match-end 0)))) |
| 5502 | (if replace | 5619 | (if replace |
| 5503 | (replace-match (concat "|" replace))) | 5620 | (replace-match (concat "|" replace))) |
| @@ -5591,9 +5708,9 @@ However, when FORCE is non-nil, create new columns if necessary." | |||
| 5591 | (looking-at org-table-hline-regexp)) | 5708 | (looking-at org-table-hline-regexp)) |
| 5592 | nil)) | 5709 | nil)) |
| 5593 | 5710 | ||
| 5594 | (defun org-table-insert-column (&optional arg) | 5711 | (defun org-table-insert-column () |
| 5595 | "Insert a new column into the table." | 5712 | "Insert a new column into the table." |
| 5596 | (interactive "P") | 5713 | (interactive) |
| 5597 | (if (not (org-at-table-p)) | 5714 | (if (not (org-at-table-p)) |
| 5598 | (error "Not at a table")) | 5715 | (error "Not at a table")) |
| 5599 | (org-table-find-dataline) | 5716 | (org-table-find-dataline) |
| @@ -5634,9 +5751,9 @@ However, when FORCE is non-nil, create new columns if necessary." | |||
| 5634 | (error | 5751 | (error |
| 5635 | "Please position cursor in a data line for column operations"))))) | 5752 | "Please position cursor in a data line for column operations"))))) |
| 5636 | 5753 | ||
| 5637 | (defun org-table-delete-column (&optional arg) | 5754 | (defun org-table-delete-column () |
| 5638 | "Delete a column into the table." | 5755 | "Delete a column into the table." |
| 5639 | (interactive "P") | 5756 | (interactive) |
| 5640 | (if (not (org-at-table-p)) | 5757 | (if (not (org-at-table-p)) |
| 5641 | (error "Not at a table")) | 5758 | (error "Not at a table")) |
| 5642 | (org-table-find-dataline) | 5759 | (org-table-find-dataline) |
| @@ -5777,9 +5894,9 @@ With prefix ARG, insert above the current line." | |||
| 5777 | (beginning-of-line 0) | 5894 | (beginning-of-line 0) |
| 5778 | (move-to-column col))) | 5895 | (move-to-column col))) |
| 5779 | 5896 | ||
| 5780 | (defun org-table-kill-row (&optional arg) | 5897 | (defun org-table-kill-row () |
| 5781 | "Delete the current row or horizontal line from the table." | 5898 | "Delete the current row or horizontal line from the table." |
| 5782 | (interactive "P") | 5899 | (interactive) |
| 5783 | (if (not (org-at-table-p)) | 5900 | (if (not (org-at-table-p)) |
| 5784 | (error "Not at a table")) | 5901 | (error "Not at a table")) |
| 5785 | (let ((col (current-column))) | 5902 | (let ((col (current-column))) |
| @@ -5788,14 +5905,11 @@ With prefix ARG, insert above the current line." | |||
| 5788 | (move-to-column col))) | 5905 | (move-to-column col))) |
| 5789 | 5906 | ||
| 5790 | 5907 | ||
| 5791 | (defun org-table-cut-region (&optional arg) | 5908 | (defun org-table-cut-region () |
| 5792 | "Copy region in table to the clipboard and blank all relevant fields." | 5909 | "Copy region in table to the clipboard and blank all relevant fields." |
| 5793 | (interactive "P") | 5910 | (interactive) |
| 5794 | (org-table-copy-region 'cut)) | 5911 | (org-table-copy-region 'cut)) |
| 5795 | 5912 | ||
| 5796 | (defvar org-table-clip nil | ||
| 5797 | "Clipboard for table regions") | ||
| 5798 | |||
| 5799 | (defun org-table-copy-region (&optional cut) | 5913 | (defun org-table-copy-region (&optional cut) |
| 5800 | "Copy rectangular region in table to clipboard. | 5914 | "Copy rectangular region in table to clipboard. |
| 5801 | A special clipboard is used which can only be accessed | 5915 | A special clipboard is used which can only be accessed |
| @@ -5832,20 +5946,19 @@ with `org-table-paste-rectangle'" | |||
| 5832 | (setq org-table-clip (nreverse region)) | 5946 | (setq org-table-clip (nreverse region)) |
| 5833 | (if cut (org-table-align)))) | 5947 | (if cut (org-table-align)))) |
| 5834 | 5948 | ||
| 5835 | (defun org-table-paste-rectangle (&optional arg) | 5949 | (defun org-table-paste-rectangle () |
| 5836 | "Paste a rectangular region into a table. | 5950 | "Paste a rectangular region into a table. |
| 5837 | The upper right corner ends up in the current field. All involved fields | 5951 | The upper right corner ends up in the current field. All involved fields |
| 5838 | will be overwritten. If the rectangle does not fit into the present table, | 5952 | will be overwritten. If the rectangle does not fit into the present table, |
| 5839 | the table is enlarged as needed. The process ignores horizontal separator | 5953 | the table is enlarged as needed. The process ignores horizontal separator |
| 5840 | lines." | 5954 | lines." |
| 5841 | (interactive "P") | 5955 | (interactive) |
| 5842 | (unless (and org-table-clip (listp org-table-clip)) | 5956 | (unless (and org-table-clip (listp org-table-clip)) |
| 5843 | (error "First cut/copy a region to paste!")) | 5957 | (error "First cut/copy a region to paste!")) |
| 5844 | (org-table-check-inside-data-field) | 5958 | (org-table-check-inside-data-field) |
| 5845 | (let* ((clip org-table-clip) | 5959 | (let* ((clip org-table-clip) |
| 5846 | (line (count-lines (point-min) (point))) | 5960 | (line (count-lines (point-min) (point))) |
| 5847 | (col (org-table-current-column)) | 5961 | (col (org-table-current-column)) |
| 5848 | (l line) | ||
| 5849 | (org-enable-table-editor t) | 5962 | (org-enable-table-editor t) |
| 5850 | (org-table-automatic-realign nil) | 5963 | (org-table-automatic-realign nil) |
| 5851 | c cols field) | 5964 | c cols field) |
| @@ -5864,7 +5977,7 @@ lines." | |||
| 5864 | (org-table-align))) | 5977 | (org-table-align))) |
| 5865 | 5978 | ||
| 5866 | (defun org-table-convert () | 5979 | (defun org-table-convert () |
| 5867 | "Convert from org-mode table to table.el and back. | 5980 | "Convert from `org-mode' table to table.el and back. |
| 5868 | Obviously, this only works within limits. When an Org-mode table is | 5981 | Obviously, this only works within limits. When an Org-mode table is |
| 5869 | converted to table.el, all horizontal separator lines get lost, because | 5982 | converted to table.el, all horizontal separator lines get lost, because |
| 5870 | table.el uses these as cell boundaries and has no notion of horizontal lines. | 5983 | table.el uses these as cell boundaries and has no notion of horizontal lines. |
| @@ -5915,7 +6028,7 @@ lines, in order to keep the table compact. | |||
| 5915 | If there is an active region, and both point and mark are in the same column, | 6028 | If there is an active region, and both point and mark are in the same column, |
| 5916 | the text in the column is wrapped to minimum width for the given number of | 6029 | the text in the column is wrapped to minimum width for the given number of |
| 5917 | lines. Generally, this makes the table more compact. A prefix ARG may be | 6030 | lines. Generally, this makes the table more compact. A prefix ARG may be |
| 5918 | used to change the number of desired lines. For example, `C-2 C-c C-q' | 6031 | used to change the number of desired lines. For example, `C-2 \\[org-table-wrap]' |
| 5919 | formats the selected text to two lines. If the region was longer than 2 | 6032 | formats the selected text to two lines. If the region was longer than 2 |
| 5920 | lines, the remaining lines remain empty. A negative prefix argument reduces | 6033 | lines, the remaining lines remain empty. A negative prefix argument reduces |
| 5921 | the current number of lines by that amount. The wrapped text is pasted back | 6034 | the current number of lines by that amount. The wrapped text is pasted back |
| @@ -5984,8 +6097,6 @@ many lines, whatever width that takes. | |||
| 5984 | The return value is a list of lines, without newlines at the end." | 6097 | The return value is a list of lines, without newlines at the end." |
| 5985 | (let* ((words (org-split-string string "[ \t\n]+")) | 6098 | (let* ((words (org-split-string string "[ \t\n]+")) |
| 5986 | (maxword (apply 'max (mapcar 'length words))) | 6099 | (maxword (apply 'max (mapcar 'length words))) |
| 5987 | (black (apply '+ (mapcar 'length words))) | ||
| 5988 | (total (+ black (length words))) | ||
| 5989 | w ll) | 6100 | w ll) |
| 5990 | (cond (width | 6101 | (cond (width |
| 5991 | (org-do-wrap words (max maxword width))) | 6102 | (org-do-wrap words (max maxword width))) |
| @@ -6003,7 +6114,7 @@ The return value is a list of lines, without newlines at the end." | |||
| 6003 | 6114 | ||
| 6004 | 6115 | ||
| 6005 | (defun org-do-wrap (words width) | 6116 | (defun org-do-wrap (words width) |
| 6006 | "Creates lines of maximum width WIDTH (in characters) from word list WORDS." | 6117 | "Create lines of maximum width WIDTH (in characters) from word list WORDS." |
| 6007 | (let (lines line) | 6118 | (let (lines line) |
| 6008 | (while words | 6119 | (while words |
| 6009 | (setq line (pop words)) | 6120 | (setq line (pop words)) |
| @@ -6222,10 +6333,10 @@ A few examples for formulae: | |||
| 6222 | $;%.1f Reformat current cell to 1 digit after dec.point | 6333 | $;%.1f Reformat current cell to 1 digit after dec.point |
| 6223 | ($3-32)*5/9 degrees F -> C conversion | 6334 | ($3-32)*5/9 degrees F -> C conversion |
| 6224 | 6335 | ||
| 6225 | When called with a raw C-u prefix, the formula is applied to the current | 6336 | When called with a raw \\[universal-argument] prefix, the formula is applied to the current |
| 6226 | field, and to the same same column in all following rows, until reaching a | 6337 | field, and to the same same column in all following rows, until reaching a |
| 6227 | horizontal line or the end of the table. When the command is called with a | 6338 | horizontal line or the end of the table. When the command is called with a |
| 6228 | numeric prefix argument (like M-3 or C-7 or C-u 24), the formula is applied | 6339 | numeric prefix argument (like M-3 or C-7 or \\[universal-argument] 24), the formula is applied |
| 6229 | to the current row, and to the following n-1 rows (but not beyond a | 6340 | to the current row, and to the following n-1 rows (but not beyond a |
| 6230 | separator line)." | 6341 | separator line)." |
| 6231 | (interactive "P") | 6342 | (interactive "P") |
| @@ -6297,7 +6408,7 @@ separator line)." | |||
| 6297 | ;; modified self-insert. | 6408 | ;; modified self-insert. |
| 6298 | 6409 | ||
| 6299 | (defcustom orgtbl-optimized (eq org-enable-table-editor 'optimized) | 6410 | (defcustom orgtbl-optimized (eq org-enable-table-editor 'optimized) |
| 6300 | "Non-nil means, use the optimized table editor version for orgtbl-mode. | 6411 | "Non-nil means, use the optimized table editor version for `orgtbl-mode'. |
| 6301 | In the optimized version, the table editor takes over all simple keys that | 6412 | In the optimized version, the table editor takes over all simple keys that |
| 6302 | normally just insert a character. In tables, the characters are inserted | 6413 | normally just insert a character. In tables, the characters are inserted |
| 6303 | in a way to minimize disturbing the table structure (i.e. in overwrite mode | 6414 | in a way to minimize disturbing the table structure (i.e. in overwrite mode |
| @@ -6311,21 +6422,21 @@ this variable requires a restart of Emacs to become effective." | |||
| 6311 | :type 'boolean) | 6422 | :type 'boolean) |
| 6312 | 6423 | ||
| 6313 | (defvar orgtbl-mode nil | 6424 | (defvar orgtbl-mode nil |
| 6314 | "Variable controlling orgtbl-mode, a minor mode enabling the org-mode | 6425 | "Variable controlling `orgtbl-mode', a minor mode enabling the `org-mode' |
| 6315 | table editor in arbitrary modes.") | 6426 | table editor in arbitrary modes.") |
| 6316 | (make-variable-buffer-local 'orgtbl-mode) | 6427 | (make-variable-buffer-local 'orgtbl-mode) |
| 6317 | 6428 | ||
| 6318 | (defvar orgtbl-mode-map (make-sparse-keymap) | 6429 | (defvar orgtbl-mode-map (make-sparse-keymap) |
| 6319 | "Keymap for orgtbl-mode.") | 6430 | "Keymap for `orgtbl-mode'.") |
| 6320 | 6431 | ||
| 6321 | ;;;###autoload | 6432 | ;;;###autoload |
| 6322 | (defun turn-on-orgtbl () | 6433 | (defun turn-on-orgtbl () |
| 6323 | "Unconditionally turn on orgtbl-mode." | 6434 | "Unconditionally turn on `orgtbl-mode'." |
| 6324 | (orgtbl-mode 1)) | 6435 | (orgtbl-mode 1)) |
| 6325 | 6436 | ||
| 6326 | ;;;###autoload | 6437 | ;;;###autoload |
| 6327 | (defun orgtbl-mode (&optional arg) | 6438 | (defun orgtbl-mode (&optional arg) |
| 6328 | "The org-mode table editor as a minor mode for use in other modes." | 6439 | "The `org-mode' table editor as a minor mode for use in other modes." |
| 6329 | (interactive) | 6440 | (interactive) |
| 6330 | (setq orgtbl-mode | 6441 | (setq orgtbl-mode |
| 6331 | (if arg (> (prefix-numeric-value arg) 0) (not orgtbl-mode))) | 6442 | (if arg (> (prefix-numeric-value arg) 0) (not orgtbl-mode))) |
| @@ -6435,13 +6546,13 @@ table editor in arbitrary modes.") | |||
| 6435 | (define-key org-mode-map "|" 'self-insert-command)) | 6546 | (define-key org-mode-map "|" 'self-insert-command)) |
| 6436 | 6547 | ||
| 6437 | (defun orgtbl-tab () | 6548 | (defun orgtbl-tab () |
| 6438 | "Justification and field motion for orgtbl-mode." | 6549 | "Justification and field motion for `orgtbl-mode'." |
| 6439 | (interactive) | 6550 | (interactive) |
| 6440 | (org-table-justify-field-maybe) | 6551 | (org-table-justify-field-maybe) |
| 6441 | (org-table-next-field)) | 6552 | (org-table-next-field)) |
| 6442 | 6553 | ||
| 6443 | (defun orgtbl-ret () | 6554 | (defun orgtbl-ret () |
| 6444 | "Justification and field motion for orgtbl-mode." | 6555 | "Justification and field motion for `orgtbl-mode'." |
| 6445 | (interactive) | 6556 | (interactive) |
| 6446 | (org-table-justify-field-maybe) | 6557 | (org-table-justify-field-maybe) |
| 6447 | (org-table-next-row)) | 6558 | (org-table-next-row)) |
| @@ -6454,7 +6565,7 @@ overwritten, and the table is not marked as requiring realignment." | |||
| 6454 | (if (and (org-at-table-p) | 6565 | (if (and (org-at-table-p) |
| 6455 | (eq N 1) | 6566 | (eq N 1) |
| 6456 | (looking-at "[^|\n]* +|")) | 6567 | (looking-at "[^|\n]* +|")) |
| 6457 | (let (org-table-may-need-update (pos (point))) | 6568 | (let (org-table-may-need-update) |
| 6458 | (goto-char (1- (match-end 0))) | 6569 | (goto-char (1- (match-end 0))) |
| 6459 | (delete-backward-char 1) | 6570 | (delete-backward-char 1) |
| 6460 | (goto-char (match-beginning 0)) | 6571 | (goto-char (match-beginning 0)) |
| @@ -6869,6 +6980,8 @@ The list contains HTML entities for Latin-1, Greek and other symbols. | |||
| 6869 | It is supplemented by a number of commonly used TeX macros with appropriate | 6980 | It is supplemented by a number of commonly used TeX macros with appropriate |
| 6870 | translations.") | 6981 | translations.") |
| 6871 | 6982 | ||
| 6983 | (defvar org-last-level nil) ; dynamically scoped variable | ||
| 6984 | |||
| 6872 | (defun org-export-as-ascii (arg) | 6985 | (defun org-export-as-ascii (arg) |
| 6873 | "Export the outline as a pretty ASCII file. | 6986 | "Export the outline as a pretty ASCII file. |
| 6874 | If there is an active region, export only the region. | 6987 | If there is an active region, export only the region. |
| @@ -6898,10 +7011,10 @@ underlined headlines. The default is 3." | |||
| 6898 | (email user-mail-address) | 7011 | (email user-mail-address) |
| 6899 | (language org-export-default-language) | 7012 | (language org-export-default-language) |
| 6900 | (text nil) | 7013 | (text nil) |
| 6901 | (last-level 1) | ||
| 6902 | (todo nil) | 7014 | (todo nil) |
| 6903 | (lang-words nil)) | 7015 | (lang-words nil)) |
| 6904 | 7016 | ||
| 7017 | (setq org-last-level 1) | ||
| 6905 | (org-init-section-numbers) | 7018 | (org-init-section-numbers) |
| 6906 | 7019 | ||
| 6907 | (find-file-noselect filename) | 7020 | (find-file-noselect filename) |
| @@ -6962,7 +7075,7 @@ underlined headlines. The default is 3." | |||
| 6962 | (insert | 7075 | (insert |
| 6963 | (make-string (* (1- level) 4) ?\ ) | 7076 | (make-string (* (1- level) 4) ?\ ) |
| 6964 | (format (if todo "%s (*)\n" "%s\n") txt)) | 7077 | (format (if todo "%s (*)\n" "%s\n") txt)) |
| 6965 | (setq last-level level)) | 7078 | (setq org-last-level level)) |
| 6966 | )))) | 7079 | )))) |
| 6967 | lines))) | 7080 | lines))) |
| 6968 | 7081 | ||
| @@ -7030,11 +7143,11 @@ underlined headlines. The default is 3." | |||
| 7030 | (setq title (concat (org-section-number level) " " title))) | 7143 | (setq title (concat (org-section-number level) " " title))) |
| 7031 | (insert title "\n" (make-string (string-width title) char) "\n")))) | 7144 | (insert title "\n" (make-string (string-width title) char) "\n")))) |
| 7032 | 7145 | ||
| 7033 | (defun org-export-copy-visible (&optional arg) | 7146 | (defun org-export-copy-visible () |
| 7034 | "Copy the visible part of the buffer to another buffer, for printing. | 7147 | "Copy the visible part of the buffer to another buffer, for printing. |
| 7035 | Also removes the first line of the buffer if it specifies a mode, | 7148 | Also removes the first line of the buffer if it specifies a mode, |
| 7036 | and all options lines." | 7149 | and all options lines." |
| 7037 | (interactive "P") | 7150 | (interactive) |
| 7038 | (let* ((filename (concat (file-name-sans-extension (buffer-file-name)) | 7151 | (let* ((filename (concat (file-name-sans-extension (buffer-file-name)) |
| 7039 | ".txt")) | 7152 | ".txt")) |
| 7040 | (buffer (find-file-noselect filename)) | 7153 | (buffer (find-file-noselect filename)) |
| @@ -7044,8 +7157,7 @@ and all options lines." | |||
| 7044 | "TITLE" "AUTHOR" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE")) | 7157 | "TITLE" "AUTHOR" "EMAIL" "TEXT" "OPTIONS" "LANGUAGE")) |
| 7045 | (if org-noutline-p "\\(\n\\|$\\)" ""))) | 7158 | (if org-noutline-p "\\(\n\\|$\\)" ""))) |
| 7046 | s e) | 7159 | s e) |
| 7047 | (save-excursion | 7160 | (with-current-buffer buffer |
| 7048 | (set-buffer buffer) | ||
| 7049 | (erase-buffer) | 7161 | (erase-buffer) |
| 7050 | (text-mode)) | 7162 | (text-mode)) |
| 7051 | (save-excursion | 7163 | (save-excursion |
| @@ -7174,7 +7286,7 @@ headlines. The default is 3. Lower levels will become bulleted lists." | |||
| 7174 | (org-open-file (buffer-file-name))) | 7286 | (org-open-file (buffer-file-name))) |
| 7175 | 7287 | ||
| 7176 | (defun org-export-as-html-batch () | 7288 | (defun org-export-as-html-batch () |
| 7177 | "Call org-export-as-html, may be used in batch processing as | 7289 | "Call `org-export-as-html', may be used in batch processing as |
| 7178 | emacs --batch | 7290 | emacs --batch |
| 7179 | --load=$HOME/lib/emacs/org.el | 7291 | --load=$HOME/lib/emacs/org.el |
| 7180 | --eval \"(setq org-export-headline-levels 2)\" | 7292 | --eval \"(setq org-export-headline-levels 2)\" |
| @@ -7199,7 +7311,6 @@ headlines. The default is 3. Lower levels will become bulleted lists." | |||
| 7199 | (org-skip-comments (org-split-string region "[\r\n]"))) | 7311 | (org-skip-comments (org-split-string region "[\r\n]"))) |
| 7200 | (lines (org-export-find-first-heading-line all_lines)) | 7312 | (lines (org-export-find-first-heading-line all_lines)) |
| 7201 | (level 0) (line "") (origline "") txt todo | 7313 | (level 0) (line "") (origline "") txt todo |
| 7202 | (last-level 1) | ||
| 7203 | (umax nil) | 7314 | (umax nil) |
| 7204 | (filename (concat (file-name-sans-extension (buffer-file-name)) | 7315 | (filename (concat (file-name-sans-extension (buffer-file-name)) |
| 7205 | ".html")) | 7316 | ".html")) |
| @@ -7220,6 +7331,7 @@ headlines. The default is 3. Lower levels will become bulleted lists." | |||
| 7220 | ) | 7331 | ) |
| 7221 | (message "Exporting...") | 7332 | (message "Exporting...") |
| 7222 | 7333 | ||
| 7334 | (setq org-last-level 1) | ||
| 7223 | (org-init-section-numbers) | 7335 | (org-init-section-numbers) |
| 7224 | 7336 | ||
| 7225 | ;; Search for the export key lines | 7337 | ;; Search for the export key lines |
| @@ -7284,15 +7396,15 @@ headlines. The default is 3. Lower levels will become bulleted lists." | |||
| 7284 | (if (<= level umax) | 7396 | (if (<= level umax) |
| 7285 | (progn | 7397 | (progn |
| 7286 | (setq head-count (+ head-count 1)) | 7398 | (setq head-count (+ head-count 1)) |
| 7287 | (if (> level last-level) | 7399 | (if (> level org-last-level) |
| 7288 | (progn | 7400 | (progn |
| 7289 | (setq cnt (- level last-level)) | 7401 | (setq cnt (- level org-last-level)) |
| 7290 | (while (>= (setq cnt (1- cnt)) 0) | 7402 | (while (>= (setq cnt (1- cnt)) 0) |
| 7291 | (insert "<ul>")) | 7403 | (insert "<ul>")) |
| 7292 | (insert "\n"))) | 7404 | (insert "\n"))) |
| 7293 | (if (< level last-level) | 7405 | (if (< level org-last-level) |
| 7294 | (progn | 7406 | (progn |
| 7295 | (setq cnt (- last-level level)) | 7407 | (setq cnt (- org-last-level level)) |
| 7296 | (while (>= (setq cnt (1- cnt)) 0) | 7408 | (while (>= (setq cnt (1- cnt)) 0) |
| 7297 | (insert "</ul>")) | 7409 | (insert "</ul>")) |
| 7298 | (insert "\n"))) | 7410 | (insert "\n"))) |
| @@ -7302,11 +7414,11 @@ headlines. The default is 3. Lower levels will become bulleted lists." | |||
| 7302 | "<li><a href=\"#sec-%d\"><span style='color:red'>%s</span></a></li>\n" | 7414 | "<li><a href=\"#sec-%d\"><span style='color:red'>%s</span></a></li>\n" |
| 7303 | "<li><a href=\"#sec-%d\">%s</a></li>\n") | 7415 | "<li><a href=\"#sec-%d\">%s</a></li>\n") |
| 7304 | head-count txt)) | 7416 | head-count txt)) |
| 7305 | (setq last-level level)) | 7417 | (setq org-last-level level)) |
| 7306 | )))) | 7418 | )))) |
| 7307 | lines) | 7419 | lines) |
| 7308 | (while (> last-level 0) | 7420 | (while (> org-last-level 0) |
| 7309 | (setq last-level (1- last-level)) | 7421 | (setq org-last-level (1- org-last-level)) |
| 7310 | (insert "</ul>\n")) | 7422 | (insert "</ul>\n")) |
| 7311 | )) | 7423 | )) |
| 7312 | (setq head-count 0) | 7424 | (setq head-count 0) |
| @@ -7537,17 +7649,14 @@ But it has the disadvantage, that no cell- or row-spanning is allowed." | |||
| 7537 | This has the advantage that cell- or row-spanning is allowed. | 7649 | This has the advantage that cell- or row-spanning is allowed. |
| 7538 | But it has the disadvantage, that Org-mode's HTML conversions cannot be used." | 7650 | But it has the disadvantage, that Org-mode's HTML conversions cannot be used." |
| 7539 | (require 'table) | 7651 | (require 'table) |
| 7540 | (save-excursion | 7652 | (with-current-buffer (get-buffer-create " org-tmp1 ") |
| 7541 | (set-buffer (get-buffer-create " org-tmp1 ")) | ||
| 7542 | (erase-buffer) | 7653 | (erase-buffer) |
| 7543 | (insert (mapconcat 'identity lines "\n")) | 7654 | (insert (mapconcat 'identity lines "\n")) |
| 7544 | (goto-char (point-min)) | 7655 | (goto-char (point-min)) |
| 7545 | (if (not (re-search-forward "|[^+]" nil t)) | 7656 | (if (not (re-search-forward "|[^+]" nil t)) |
| 7546 | (error "Error processing table.")) | 7657 | (error "Error processing table.")) |
| 7547 | (table-recognize-table) | 7658 | (table-recognize-table) |
| 7548 | (save-excursion | 7659 | (with-current-buffer (get-buffer-create " org-tmp2 ") (erase-buffer)) |
| 7549 | (set-buffer (get-buffer-create " org-tmp2 ")) | ||
| 7550 | (erase-buffer)) | ||
| 7551 | (table-generate-source 'html " org-tmp2 ") | 7660 | (table-generate-source 'html " org-tmp2 ") |
| 7552 | (set-buffer " org-tmp2 ") | 7661 | (set-buffer " org-tmp2 ") |
| 7553 | (buffer-substring (point-min) (point-max)))) | 7662 | (buffer-substring (point-min) (point-max)))) |
| @@ -7711,7 +7820,7 @@ stacked delimiters is N. Escaping delimiters is not possible." | |||
| 7711 | level head-count title level)) | 7820 | level head-count title level)) |
| 7712 | (insert (format "\n<H%d>%s</H%d>\n" level title level)))))) | 7821 | (insert (format "\n<H%d>%s</H%d>\n" level title level)))))) |
| 7713 | 7822 | ||
| 7714 | (defun org-html-level-close (level) | 7823 | (defun org-html-level-close (&rest args) |
| 7715 | "Terminate one level in HTML export." | 7824 | "Terminate one level in HTML export." |
| 7716 | (insert "</ul>")) | 7825 | (insert "</ul>")) |
| 7717 | 7826 | ||
| @@ -7800,6 +7909,7 @@ When LEVEL is non-nil, increase section numbers on that level." | |||
| 7800 | (define-key org-mode-map "\C-c/" 'org-occur) ; Minor-mode reserved | 7909 | (define-key org-mode-map "\C-c/" 'org-occur) ; Minor-mode reserved |
| 7801 | (define-key org-mode-map "\C-c\C-m" 'org-insert-heading) | 7910 | (define-key org-mode-map "\C-c\C-m" 'org-insert-heading) |
| 7802 | (define-key org-mode-map "\M-\C-m" 'org-insert-heading) | 7911 | (define-key org-mode-map "\M-\C-m" 'org-insert-heading) |
| 7912 | (define-key org-mode-map [(meta shift return)] 'org-insert-todo-heading) | ||
| 7803 | (define-key org-mode-map "\C-c\C-l" 'org-insert-link) | 7913 | (define-key org-mode-map "\C-c\C-l" 'org-insert-link) |
| 7804 | (define-key org-mode-map "\C-c\C-o" 'org-open-at-point) | 7914 | (define-key org-mode-map "\C-c\C-o" 'org-open-at-point) |
| 7805 | (define-key org-mode-map "\C-c\C-z" 'org-time-stamp) ; Alternative binding | 7915 | (define-key org-mode-map "\C-c\C-z" 'org-time-stamp) ; Alternative binding |
| @@ -7811,8 +7921,6 @@ When LEVEL is non-nil, increase section numbers on that level." | |||
| 7811 | (define-key org-mode-map "\C-c[" 'org-add-file) | 7921 | (define-key org-mode-map "\C-c[" 'org-add-file) |
| 7812 | (define-key org-mode-map "\C-c]" 'org-remove-file) | 7922 | (define-key org-mode-map "\C-c]" 'org-remove-file) |
| 7813 | (define-key org-mode-map "\C-c\C-r" 'org-timeline) | 7923 | (define-key org-mode-map "\C-c\C-r" 'org-timeline) |
| 7814 | ;(define-key org-mode-map [(shift up)] 'org-timestamp-up) | ||
| 7815 | ;(define-key org-mode-map [(shift down)] 'org-timestamp-down) | ||
| 7816 | (define-key org-mode-map [(shift up)] 'org-shiftup) | 7924 | (define-key org-mode-map [(shift up)] 'org-shiftup) |
| 7817 | (define-key org-mode-map [(shift down)] 'org-shiftdown) | 7925 | (define-key org-mode-map [(shift down)] 'org-shiftdown) |
| 7818 | (define-key org-mode-map [(shift left)] 'org-timestamp-down-day) | 7926 | (define-key org-mode-map [(shift left)] 'org-timestamp-down-day) |
| @@ -7864,7 +7972,7 @@ overwritten, and the table is not marked as requiring realignment." | |||
| 7864 | (if (and (org-table-p) | 7972 | (if (and (org-table-p) |
| 7865 | (eq N 1) | 7973 | (eq N 1) |
| 7866 | (looking-at "[^|\n]* +|")) | 7974 | (looking-at "[^|\n]* +|")) |
| 7867 | (let (org-table-may-need-update (pos (point))) | 7975 | (let (org-table-may-need-update) |
| 7868 | (goto-char (1- (match-end 0))) | 7976 | (goto-char (1- (match-end 0))) |
| 7869 | (delete-backward-char 1) | 7977 | (delete-backward-char 1) |
| 7870 | (goto-char (match-beginning 0)) | 7978 | (goto-char (match-beginning 0)) |
| @@ -7935,25 +8043,27 @@ a reduced column width." | |||
| 7935 | ((org-at-table-p) (org-table-previous-field)) | 8043 | ((org-at-table-p) (org-table-previous-field)) |
| 7936 | (t (org-cycle '(4))))) | 8044 | (t (org-cycle '(4))))) |
| 7937 | 8045 | ||
| 7938 | (defun org-shiftmetaleft (&optional arg) | 8046 | (defun org-shiftmetaleft () |
| 7939 | "Call `org-promote-subtree' or `org-table-delete-column'." | 8047 | "Call `org-promote-subtree' or `org-table-delete-column'." |
| 7940 | (interactive "P") | 8048 | (interactive) |
| 7941 | (cond | 8049 | (cond |
| 7942 | ((org-at-table-p) (org-table-delete-column arg)) | 8050 | ((org-at-table-p) (org-table-delete-column)) |
| 7943 | ((org-on-heading-p) (org-promote-subtree arg)) | 8051 | ((org-on-heading-p) (org-promote-subtree)) |
| 7944 | (t (org-shiftcursor-error)))) | 8052 | (t (org-shiftcursor-error)))) |
| 7945 | (defun org-shiftmetaright (&optional arg) | 8053 | |
| 8054 | (defun org-shiftmetaright () | ||
| 7946 | "Call `org-demote-subtree' or `org-table-insert-column'." | 8055 | "Call `org-demote-subtree' or `org-table-insert-column'." |
| 7947 | (interactive "P") | 8056 | (interactive) |
| 7948 | (cond | 8057 | (cond |
| 7949 | ((org-at-table-p) (org-table-insert-column arg)) | 8058 | ((org-at-table-p) (org-table-insert-column)) |
| 7950 | ((org-on-heading-p) (org-demote-subtree arg)) | 8059 | ((org-on-heading-p) (org-demote-subtree)) |
| 7951 | (t (org-shiftcursor-error)))) | 8060 | (t (org-shiftcursor-error)))) |
| 8061 | |||
| 7952 | (defun org-shiftmetaup (&optional arg) | 8062 | (defun org-shiftmetaup (&optional arg) |
| 7953 | "Call `org-move-subtree-up' or `org-table-kill-row'." | 8063 | "Call `org-move-subtree-up' or `org-table-kill-row'." |
| 7954 | (interactive "P") | 8064 | (interactive "P") |
| 7955 | (cond | 8065 | (cond |
| 7956 | ((org-at-table-p) (org-table-kill-row arg)) | 8066 | ((org-at-table-p) (org-table-kill-row)) |
| 7957 | ((org-on-heading-p) (org-move-subtree-up arg)) | 8067 | ((org-on-heading-p) (org-move-subtree-up arg)) |
| 7958 | (t (org-shiftcursor-error)))) | 8068 | (t (org-shiftcursor-error)))) |
| 7959 | (defun org-shiftmetadown (&optional arg) | 8069 | (defun org-shiftmetadown (&optional arg) |
| @@ -7969,15 +8079,17 @@ a reduced column width." | |||
| 7969 | (interactive "P") | 8079 | (interactive "P") |
| 7970 | (cond | 8080 | (cond |
| 7971 | ((org-at-table-p) (org-table-move-column 'left)) | 8081 | ((org-at-table-p) (org-table-move-column 'left)) |
| 7972 | ((or (org-on-heading-p) (org-region-active-p)) (org-do-promote arg)) | 8082 | ((or (org-on-heading-p) (org-region-active-p)) (org-do-promote)) |
| 7973 | (t (backward-word (prefix-numeric-value arg))))) | 8083 | (t (backward-word (prefix-numeric-value arg))))) |
| 8084 | |||
| 7974 | (defun org-metaright (&optional arg) | 8085 | (defun org-metaright (&optional arg) |
| 7975 | "Call `org-do-demote' or `org-table-move-column' to right." | 8086 | "Call `org-do-demote' or `org-table-move-column' to right." |
| 7976 | (interactive "P") | 8087 | (interactive "P") |
| 7977 | (cond | 8088 | (cond |
| 7978 | ((org-at-table-p) (org-table-move-column nil)) | 8089 | ((org-at-table-p) (org-table-move-column nil)) |
| 7979 | ((or (org-on-heading-p) (org-region-active-p)) (org-do-demote arg)) | 8090 | ((or (org-on-heading-p) (org-region-active-p)) (org-do-demote)) |
| 7980 | (t (forward-word (prefix-numeric-value arg))))) | 8091 | (t (forward-word (prefix-numeric-value arg))))) |
| 8092 | |||
| 7981 | (defun org-metaup (&optional arg) | 8093 | (defun org-metaup (&optional arg) |
| 7982 | "Call `org-move-subtree-up' or `org-table-move-row' up." | 8094 | "Call `org-move-subtree-up' or `org-table-move-row' up." |
| 7983 | (interactive "P") | 8095 | (interactive "P") |
| @@ -7985,6 +8097,7 @@ a reduced column width." | |||
| 7985 | ((org-at-table-p) (org-table-move-row 'up)) | 8097 | ((org-at-table-p) (org-table-move-row 'up)) |
| 7986 | ((org-on-heading-p) (org-move-subtree-up arg)) | 8098 | ((org-on-heading-p) (org-move-subtree-up arg)) |
| 7987 | (t (org-shiftcursor-error)))) | 8099 | (t (org-shiftcursor-error)))) |
| 8100 | |||
| 7988 | (defun org-metadown (&optional arg) | 8101 | (defun org-metadown (&optional arg) |
| 7989 | "Call `org-move-subtree-down' or `org-table-move-row' down." | 8102 | "Call `org-move-subtree-down' or `org-table-move-row' down." |
| 7990 | (interactive "P") | 8103 | (interactive "P") |
| @@ -8007,25 +8120,25 @@ a reduced column width." | |||
| 8007 | ((org-at-timestamp-p) (org-timestamp-down arg)) | 8120 | ((org-at-timestamp-p) (org-timestamp-down arg)) |
| 8008 | (t (org-priority-down)))) | 8121 | (t (org-priority-down)))) |
| 8009 | 8122 | ||
| 8010 | (defun org-copy-special (arg) | 8123 | (defun org-copy-special () |
| 8011 | "Call either `org-table-copy' or `org-copy-subtree'." | 8124 | "Call either `org-table-copy' or `org-copy-subtree'." |
| 8012 | (interactive "P") | 8125 | (interactive) |
| 8013 | (if (org-at-table-p) | 8126 | (if (org-at-table-p) |
| 8014 | (org-table-copy-region arg) | 8127 | (org-table-copy-region) |
| 8015 | (org-copy-subtree arg))) | 8128 | (org-copy-subtree))) |
| 8016 | 8129 | ||
| 8017 | (defun org-cut-special (arg) | 8130 | (defun org-cut-special () |
| 8018 | "Call either `org-table-copy' or `org-copy-subtree'." | 8131 | "Call either `org-table-copy' or `org-cut-subtree'." |
| 8019 | (interactive "P") | 8132 | (interactive) |
| 8020 | (if (org-at-table-p) | 8133 | (if (org-at-table-p) |
| 8021 | (org-table-cut-region arg) | 8134 | (org-table-cut-region) |
| 8022 | (org-cut-subtree arg))) | 8135 | (org-cut-subtree))) |
| 8023 | 8136 | ||
| 8024 | (defun org-paste-special (arg) | 8137 | (defun org-paste-special (arg) |
| 8025 | "Call either `org-table-paste-rectangle' or `org-paste-subtree'." | 8138 | "Call either `org-table-paste-rectangle' or `org-paste-subtree'." |
| 8026 | (interactive "P") | 8139 | (interactive "P") |
| 8027 | (if (org-at-table-p) | 8140 | (if (org-at-table-p) |
| 8028 | (org-table-paste-rectangle arg) | 8141 | (org-table-paste-rectangle) |
| 8029 | (org-paste-subtree arg))) | 8142 | (org-paste-subtree arg))) |
| 8030 | 8143 | ||
| 8031 | (defun org-ctrl-c-ctrl-c (&optional arg) | 8144 | (defun org-ctrl-c-ctrl-c (&optional arg) |
| @@ -8040,12 +8153,12 @@ the automatic table editor has been turned off." | |||
| 8040 | ((org-at-table.el-p) | 8153 | ((org-at-table.el-p) |
| 8041 | (require 'table) | 8154 | (require 'table) |
| 8042 | (beginning-of-line 1) | 8155 | (beginning-of-line 1) |
| 8043 | (re-search-forward "|" (save-excursion (end-of-line 2) (point))) | 8156 | (re-search-forward "|" (save-excursion (end-of-line 2) (point))) ;FIXME: line-end-position? |
| 8044 | (table-recognize-table)) | 8157 | (table-recognize-table)) |
| 8045 | ((org-at-table-p) | 8158 | ((org-at-table-p) |
| 8046 | (org-table-align)) | 8159 | (org-table-align)) |
| 8047 | ((save-excursion (beginning-of-line 1) (looking-at "#\\+[A-Z]+")) | 8160 | ((save-excursion (beginning-of-line 1) (looking-at "#\\+[A-Z]+")) |
| 8048 | (let (org-inhibit-startup) (org-mode))) | 8161 | (let ((org-inhibit-startup t)) (org-mode))) |
| 8049 | ((org-region-active-p) | 8162 | ((org-region-active-p) |
| 8050 | (org-table-convert-region (region-beginning) (region-end) arg)) | 8163 | (org-table-convert-region (region-beginning) (region-end) arg)) |
| 8051 | ((and (region-beginning) (region-end)) | 8164 | ((and (region-beginning) (region-end)) |
| @@ -8054,9 +8167,9 @@ the automatic table editor has been turned off." | |||
| 8054 | (error "Abort"))) | 8167 | (error "Abort"))) |
| 8055 | (t (error "No table at point, and no region to make one."))))) | 8168 | (t (error "No table at point, and no region to make one."))))) |
| 8056 | 8169 | ||
| 8057 | (defun org-return (&optional arg) | 8170 | (defun org-return () |
| 8058 | "Call `org-table-next-row' or `newline'." | 8171 | "Call `org-table-next-row' or `newline'." |
| 8059 | (interactive "P") | 8172 | (interactive) |
| 8060 | (cond | 8173 | (cond |
| 8061 | ((org-at-table-p) | 8174 | ((org-at-table-p) |
| 8062 | (org-table-justify-field-maybe) | 8175 | (org-table-justify-field-maybe) |
| @@ -8069,7 +8182,7 @@ the automatic table editor has been turned off." | |||
| 8069 | (cond | 8182 | (cond |
| 8070 | ((org-at-table-p) | 8183 | ((org-at-table-p) |
| 8071 | (org-table-wrap-region arg)) | 8184 | (org-table-wrap-region arg)) |
| 8072 | (t (org-insert-heading arg)))) | 8185 | (t (org-insert-heading)))) |
| 8073 | 8186 | ||
| 8074 | ;;; Menu entries | 8187 | ;;; Menu entries |
| 8075 | 8188 | ||
| @@ -8256,7 +8369,7 @@ With optional NODE, go directly to that node." | |||
| 8256 | ;;; Miscellaneous stuff | 8369 | ;;; Miscellaneous stuff |
| 8257 | 8370 | ||
| 8258 | (defun org-move-line-down (arg) | 8371 | (defun org-move-line-down (arg) |
| 8259 | "Move the current line up." | 8372 | "Move the current line down. With prefix argument, move it past ARG lines." |
| 8260 | (interactive "p") | 8373 | (interactive "p") |
| 8261 | (let ((col (current-column)) | 8374 | (let ((col (current-column)) |
| 8262 | beg end pos) | 8375 | beg end pos) |
| @@ -8269,13 +8382,13 @@ With optional NODE, go directly to that node." | |||
| 8269 | (move-to-column col))) | 8382 | (move-to-column col))) |
| 8270 | 8383 | ||
| 8271 | (defun org-move-line-up (arg) | 8384 | (defun org-move-line-up (arg) |
| 8272 | "Move the current line up." | 8385 | "Move the current line up. With prefix argument, move it past ARG lines." |
| 8273 | (interactive "p") | 8386 | (interactive "p") |
| 8274 | (let ((col (current-column)) | 8387 | (let ((col (current-column)) |
| 8275 | beg end pos) | 8388 | beg end pos) |
| 8276 | (beginning-of-line 1) (setq beg (point)) | 8389 | (beginning-of-line 1) (setq beg (point)) |
| 8277 | (beginning-of-line 2) (setq end (point)) | 8390 | (beginning-of-line 2) (setq end (point)) |
| 8278 | (beginning-of-line (+ -2 arg)) | 8391 | (beginning-of-line (- arg)) |
| 8279 | (setq pos (move-marker (make-marker) (point))) | 8392 | (setq pos (move-marker (make-marker) (point))) |
| 8280 | (insert (delete-and-extract-region beg end)) | 8393 | (insert (delete-and-extract-region beg end)) |
| 8281 | (goto-char pos) | 8394 | (goto-char pos) |
| @@ -8284,7 +8397,7 @@ With optional NODE, go directly to that node." | |||
| 8284 | ;; Functions needed for Emacs/XEmacs region compatibility | 8397 | ;; Functions needed for Emacs/XEmacs region compatibility |
| 8285 | 8398 | ||
| 8286 | (defun org-region-active-p () | 8399 | (defun org-region-active-p () |
| 8287 | "Is transient-mark-mode on and the region active? | 8400 | "Is `transient-mark-mode' on and the region active? |
| 8288 | Works on both Emacs and XEmacs." | 8401 | Works on both Emacs and XEmacs." |
| 8289 | (if org-ignore-region | 8402 | (if org-ignore-region |
| 8290 | nil | 8403 | nil |
| @@ -8403,7 +8516,9 @@ If INVISIBLE-OK is non-nil, an invisible heading line is ok too." | |||
| 8403 | This function considers both visible and invisible heading lines. | 8516 | This function considers both visible and invisible heading lines. |
| 8404 | With argument, move up ARG levels." | 8517 | With argument, move up ARG levels." |
| 8405 | (if org-noutline-p | 8518 | (if org-noutline-p |
| 8406 | (outline-up-heading arg t) | 8519 | (if (fboundp 'outline-up-heading-all) |
| 8520 | (outline-up-heading-all arg) ; emacs 21 version of outline.el | ||
| 8521 | (outline-up-heading arg t)) ; emacs 22 version of outline.el | ||
| 8407 | (org-back-to-heading t) | 8522 | (org-back-to-heading t) |
| 8408 | (looking-at outline-regexp) | 8523 | (looking-at outline-regexp) |
| 8409 | (if (<= (- (match-end 0) (match-beginning 0)) arg) | 8524 | (if (<= (- (match-end 0) (match-beginning 0)) arg) |
| @@ -8422,7 +8537,7 @@ With argument, move up ARG levels." | |||
| 8422 | (progn | 8537 | (progn |
| 8423 | (org-back-to-heading t) | 8538 | (org-back-to-heading t) |
| 8424 | (org-flag-heading nil))) | 8539 | (org-flag-heading nil))) |
| 8425 | (show-entry))) | 8540 | (org-show-entry))) |
| 8426 | 8541 | ||
| 8427 | (defun org-check-occur-regexp (regexp) | 8542 | (defun org-check-occur-regexp (regexp) |
| 8428 | "If REGEXP starts with \"^\", modify it to check for \\r as well. | 8543 | "If REGEXP starts with \"^\", modify it to check for \\r as well. |
| @@ -8444,7 +8559,7 @@ When ENTRY is non-nil, show the entire entry." | |||
| 8444 | ;; Check if we should show the entire entry | 8559 | ;; Check if we should show the entire entry |
| 8445 | (if entry | 8560 | (if entry |
| 8446 | (progn | 8561 | (progn |
| 8447 | (show-entry) | 8562 | (org-show-entry) |
| 8448 | (save-excursion ;; FIXME: Is this the fix for points in the -| | 8563 | (save-excursion ;; FIXME: Is this the fix for points in the -| |
| 8449 | ;; middle of text? | | 8564 | ;; middle of text? | |
| 8450 | (and (outline-next-heading) ;; | | 8565 | (and (outline-next-heading) ;; | |
| @@ -8455,6 +8570,28 @@ When ENTRY is non-nil, show the entire entry." | |||
| 8455 | flag | 8570 | flag |
| 8456 | (if flag ?\r ?\n)))))) | 8571 | (if flag ?\r ?\n)))))) |
| 8457 | 8572 | ||
| 8573 | (defun org-show-subtree () | ||
| 8574 | "Show everything after this heading at deeper levels." | ||
| 8575 | (outline-flag-region | ||
| 8576 | (point) | ||
| 8577 | (save-excursion | ||
| 8578 | (outline-end-of-subtree) (outline-next-heading) (point)) | ||
| 8579 | (if org-noutline-p nil ?\n))) | ||
| 8580 | |||
| 8581 | (defun org-show-entry () | ||
| 8582 | "Show the body directly following this heading. | ||
| 8583 | Show the heading too, if it is currently invisible." | ||
| 8584 | (interactive) | ||
| 8585 | (save-excursion | ||
| 8586 | (org-back-to-heading t) | ||
| 8587 | (outline-flag-region | ||
| 8588 | (1- (point)) | ||
| 8589 | (save-excursion | ||
| 8590 | (re-search-forward (concat "[\r\n]\\(" outline-regexp "\\)") nil 'move) | ||
| 8591 | (or (match-beginning 1) (point-max))) | ||
| 8592 | (if org-noutline-p nil ?\n)))) | ||
| 8593 | |||
| 8594 | |||
| 8458 | (defun org-make-options-regexp (kwds) | 8595 | (defun org-make-options-regexp (kwds) |
| 8459 | "Make a regular expression for keyword lines." | 8596 | "Make a regular expression for keyword lines." |
| 8460 | (concat | 8597 | (concat |