diff --git a/Makefile b/Makefile index cf80ef3a8..e4577a558 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,7 @@ CP = cp -p ##---------------------------------------------------------------------- # The following variables need to be defined by the maintainer -LISPFILES = org.el org-publish.el org-install.el +LISPFILES = org.el org-publish.el org-mouse.el org-install.el ELCFILES = $(LISPFILES:.el=.elc) TEXIFILES = org.texi INFOFILES = org diff --git a/org b/org index 12ff26f49..705aa3ebb 100644 --- a/org +++ b/org @@ -5,7 +5,7 @@ START-INFO-DIR-ENTRY * Org Mode: (org). outline-based notes management and organizer END-INFO-DIR-ENTRY - This manual is for Org-mode (version 4.52). + This manual is for Org-mode (version 4.53). Copyright (C) 2004, 2005, 2006 Free Software Foundation @@ -27,7 +27,7 @@ File: org, Node: Top, Next: Introduction, Prev: (dir), Up: (dir) Org Mode Manual *************** -This manual is for Org-mode (version 4.52). +This manual is for Org-mode (version 4.53). Copyright (C) 2004, 2005, 2006 Free Software Foundation @@ -139,11 +139,12 @@ Timestamps * Time stamps:: Assigning a time to a tree entry * Creating timestamps:: Commands which insert timestamps +* Custom time format:: If you cannot work with the ISO format * Progress logging:: Documenting when what work was done. Creating timestamps -* The date/time prompt:: +* The date/time prompt:: How org-mode helps you entring date and time Progress Logging @@ -286,6 +287,15 @@ can be exported as a structured ASCII file, as HTML, or (todo and agenda items only) as an iCalendar file. It can also serve as a publishing tool for a set of linked webpages. + An important design aspect that distinguishes Org-mode from other +packages like Planner/Muse is that it encougages to store every piece of +information only once. In Planner, you have project pages, day pages +and possibly other files, duplicating some information such as tasks. +In Org-mode, you only have notes files. In your notes you mark entries +as tasks, label them with tags and timestamps. All necessary lists like +a schedule for the day, the agenda for a meeting, tasks lists selected +by tags etc are created dynamically when you need them. + Org-mode keeps simple things simple. When first fired up, it should feel like a straightforward, easy to use outliner. Complexity is not imposed, but a large amount of functionality is available when you need @@ -297,11 +307,12 @@ example: * as an ASCII table editor with spreadsheet-like capabilities * as a TODO list editor * as a full agenda and planner with deadlines and work scheduling + * as an environment to implement David Allen's GTD system * as a simple hypertext system, with HTML export * as a publishing tool to create a set of interlinked webpages - The Org-mode table editor can be integrated into any major mode by -activating the minor Orgtbl-mode. + Org-mode's automatic, context sensitive table editor can be +integrated into any major mode by activating the minor Orgtbl-mode. There is a website for Org-mode which provides links to the newest version of Org-mode, as well as additional information, frequently asked @@ -554,7 +565,10 @@ File: org, Node: Structure editing, Next: Archiving, Prev: Motion, Up: Docum rest of the line becomes the new headline. If the command is used at the beginning of a headline, the new headline is created before the current line. If at the beginning of any other line, the - content of that line is made the new heading. + content of that line is made the new heading. If the command is + used at the end of a folded subtree (i.e. behind the ellipses at + the end of a headline), then a headline like the current one will + be inserted after the end of the subtree. `M-S-' Insert new TODO entry with same level as current heading. @@ -2215,6 +2229,7 @@ planning. * Time stamps:: Assigning a time to a tree entry * Creating timestamps:: Commands which insert timestamps +* Custom time format:: If you cannot work with the ISO format * Progress logging:: Documenting when what work was done.  @@ -2224,10 +2239,11 @@ File: org, Node: Time stamps, Next: Creating timestamps, Prev: Timestamps, U ========================================= A time stamp is a specification of a date (possibly with time) in a -special format, either `<2003-09-16 Tue>' or `<2003-09-16 Tue 09:39>'. -A time stamp can appear anywhere in the headline or body of an org-tree -entry. Its presence allows entries to be shown on specific dates in -the agenda (*note Weekly/Daily agenda::). We distinguish: +special format, either `<2003-09-16 Tue>' or `<2003-09-16 Tue +09:39>'(1). A time stamp can appear anywhere in the headline or body +of an org-tree entry. Its presence allows entries to be shown on +specific dates in the agenda (*note Weekly/Daily agenda::). We +distinguish: PLAIN TIME STAMP A simple time stamp just assigns a date/time to an item. This is @@ -2237,6 +2253,15 @@ PLAIN TIME STAMP headline of an entry associated with a plain time stamp will be shown exactly on that date. + * Meet Peter at the movies <2006-11-01 Wed 19:15> + +INACTIVE TIME STAMP + Just like a plain time stamp, but with square brackets instead of + angular ones. These time stamps are inactive in the sense that + thay do _not_ trigger an entry to show up in the agenda. + + * Gillian comes late for the fifth time [2006-11-01 Wed] + TIME STAMP RANGE Two time stamps connected by `--' denote a time range. The headline will be shown on the first and last day of the range, and @@ -2284,8 +2309,13 @@ TIME RANGE WITH CLOCK KEYWORD enclosed in square brackets instead of angular brackets. *Note Clocking work time::. + ---------- Footnotes ---------- + + (1) This is the standard ISO date/time format. If you cannot get +used to these, see *Note Custom time format:: +  -File: org, Node: Creating timestamps, Next: Progress logging, Prev: Time stamps, Up: Timestamps +File: org, Node: Creating timestamps, Next: Custom time format, Prev: Time stamps, Up: Timestamps 6.2 Creating timestamps ======================= @@ -2318,8 +2348,8 @@ format. timestamp in the current line, goto the corresponding date instead. `C-c C-o' - Access the agenda for the date given by the time stamp at point - (*note Weekly/Daily agenda::). + Access the agenda for the date given by the time stamp or -range at + point (*note Weekly/Daily agenda::). `C-c C-d' Insert `DEADLINE' keyword along with a stamp. The insertion will @@ -2346,9 +2376,9 @@ format. `S-' Change the item under the cursor in a timestamp. The cursor can be on a year, month, day, hour or minute. Note that if the cursor - is not at a time stamp, these same keys modify the priority of an - item. (*note Priorities::). The key bindings also conflict with - CUA-mode (*note Conflicts::). + is in a headline and not at a time stamp, these same keys modify + the priority of an item. (*note Priorities::). The key bindings + also conflict with CUA-mode (*note Conflicts::). `C-c C-y' Evaluate a time range by computing the difference between start and @@ -2357,7 +2387,7 @@ format. * Menu: -* The date/time prompt:: +* The date/time prompt:: How org-mode helps you entring date and time  File: org, Node: The date/time prompt, Prev: Creating timestamps, Up: Creating timestamps @@ -2415,7 +2445,8 @@ can control the calendar fully from the minibuffer: One month back. `' - Choose date in calendar (only if nothing typed into minibuffer). + Choose date in calendar (only if nothing was typed into + minibuffer). ---------- Footnotes ---------- @@ -2423,9 +2454,45 @@ can control the calendar fully from the minibuffer: `org-popup-calendar-for-date-prompt'.  -File: org, Node: Progress logging, Prev: Creating timestamps, Up: Timestamps +File: org, Node: Custom time format, Next: Progress logging, Prev: Creating timestamps, Up: Timestamps -6.3 Progress Logging +6.3 Custom time format +====================== + +Org-mode uses the standard ISO notation for dates and times as it is +defined in ISO 8601. If you cannot get used to this and require another +representation of date and time to keep you happy, you can get it by +customizing the variables `org-display-custom-times' and +`org-time-stamp-custom-formats'. + +`C-c C-x C-t' + Toggle the display of custom formats for dates and times. + +Org-mode needs the default format for scanning, so the custom date/time +format does not _replace_ the default format - instead it is put _over_ +the default format using text properties. This has the following +consequences: + * You cannot place the cursor onto a time stamp anymore, only before + or after. + + * The `S-/' keys can no longer be used to adjust each + component of a time stamp. If the cursor is at the beginning of + the stamp, `S-/' will change the stamp by one day, just + like `S-/'. At the end of the stamp, the time will + be changed by one minute. + + * When you delete a time stamp character-by-character, it will only + disappear from the buffer after _all_ (invisible) characters + belonging to the ISO timestamp have been removed. + + * If the custom time stamp format is longer than the default and you + are using dates in tables, table alignment will be messed up. If + the custom format is shorter, things do work as expected. + + +File: org, Node: Progress logging, Prev: Custom time format, Up: Timestamps + +6.4 Progress Logging ==================== Org-mode can automatically record a time stamp when you mark a TODO item @@ -2441,7 +2508,7 @@ stop working on an aspect of a project.  File: org, Node: Closing items, Next: Clocking work time, Prev: Progress logging, Up: Progress logging -6.3.1 Closing items +6.4.1 Closing items ------------------- If you want to keep track of _when_ a certain TODO item was finished, @@ -2462,7 +2529,7 @@ possibility to record an additional note together with a timestamp.  File: org, Node: Clocking work time, Prev: Closing items, Up: Progress logging -6.3.2 Clocking work time +6.4.2 Clocking work time ------------------------ Org-mode allows you to clock the time you spent on specific tasks in a @@ -2479,7 +2546,8 @@ also computes the total time spent on each subtree of a project. Stop the clock (clock-out). The inserts another timestamp at the same location where the clock was last started. It also directly computes the resulting time in inserts it after the time range as - `=> HH:MM'. + `=> HH:MM'. See the variable `org-log-done' for the possibility to + record an additional note together with a the clock-out time stamp. `C-c C-y' Recompute the time interval after changing one of the time stamps. @@ -2499,7 +2567,8 @@ also computes the total time spent on each subtree of a project. This puts overlays at the end of each headline, showing the total time recorded under that heading, including the time of any subheadings. You can use visibility cycling to study the tree, but - the overlays disappear automatically when the buffer is changed. + the overlays disappear when you change the buffer (see variable + `org-remove-highlights-with-change') or press `C-c C-c'. `C-c C-x C-r' Insert a dynamic block (*note Dynamic blocks::) containing a clock @@ -2535,9 +2604,6 @@ also computes the total time spent on each subtree of a project. the agenda (*note Weekly/Daily agenda::) to show which tasks have been worked on or closed during a day. - See the variable `org-log-done' for the possibility to record an -additional note together with a the clock-out time stamp. - ---------- Footnotes ---------- (1) Note that all parameters must be specified in a single line - @@ -2725,21 +2791,21 @@ operator `&' is optional when `+' or `-' is present. Examples: If you are using multi-state TODO keywords (*note TODO extensions::), it can be useful to also match on the TODO keyword. -This can be done by adding a condition after a double slash to a tags -match. The syntax is similar to the tag matches, but should be applied -with consideration: For example, a positive selection on several TODO +This can be done by adding a condition after a slash to a tags match. +The syntax is similar to the tag matches, but should be applied with +consideration: For example, a positive selection on several TODO keywords can not meaningfully be combined with boolean AND. However, _negative selection_ combined with AND can be meaningful. Examples: -`WORK//WAITING' +`WORK/WAITING' Select `:WORK:'-tagged TODO lines with the specific TODO keyword `WAITING'. -`WORK//-WAITING-NEXT' +`WORK/-WAITING-NEXT' Select `:WORK:'-tagged TODO lines that are neither `WAITING' nor `NEXT' -`WORK//+WAITING|+NEXT' +`WORK/+WAITING|+NEXT' Select `:WORK:'-tagged TODO lines that are either `WAITING' or `NEXT'. @@ -4487,6 +4553,10 @@ file is visited again in a new Emacs session. showstars show all stars starting a headline odd allow only odd outline levels (1,3,...) oddeven allow all outline levels + To turn on custom format overlayes over time stamps (variables + `org-put-time-stamp-overlays' and + `org-time-stamp-overlay-formats'), use + customtime overlay custom time format `#+SEQ_TODO: #+TYP_TODO:' These lines set the TODO keywords and their interpretation in the @@ -5065,7 +5135,7 @@ Index * active region <2>: ASCII export. (line 9) * active region <3>: Built-in table editor. (line 165) -* active region: Structure editing. (line 51) +* active region: Structure editing. (line 54) * agenda: Weekly/Daily agenda. (line 6) * agenda dispatcher: Agenda dispatcher. (line 6) * agenda files: Agenda files. (line 6) @@ -5110,8 +5180,8 @@ Index * checkboxes: Checkboxes. (line 6) * children, subtree visibility state: Visibility cycling. (line 10) * clean outline view: Clean view. (line 6) -* CLOCK keyword: Time stamps. (line 61) -* CLOSED keyword: Time stamps. (line 55) +* CLOCK keyword: Time stamps. (line 71) +* CLOSED keyword: Time stamps. (line 65) * column formula: Column formulas. (line 6) * commands, in agenda buffer: Agenda commands. (line 6) * comment lines: Comment lines. (line 6) @@ -5135,17 +5205,19 @@ Index * creating timestamps: Creating timestamps. (line 6) * CUA.el: Conflicts. (line 15) * custom agenda views: Custom agenda views. (line 6) +* custom date/time format: Custom time format. (line 6) * custom search strings: Custom searches. (line 6) * customization: Customization. (line 6) * cutting, of subtrees: Structure editing. (line 6) * cycling, of TODO states: TODO basics. (line 13) * cycling, visibility: Visibility cycling. (line 6) * daily agenda: Weekly/Daily agenda. (line 6) +* date format, custom: Custom time format. (line 6) * date stamps <1>: Time stamps. (line 6) * date stamps: Timestamps. (line 6) * date, reading in minibuffer: The date/time prompt. (line 6) -* DEADLINE keyword: Time stamps. (line 43) +* DEADLINE keyword: Time stamps. (line 53) * deadlines: Time stamps. (line 6) * demotion, of subtrees: Structure editing. (line 6) * diary entries, creating from agenda: Agenda commands. (line 179) @@ -5171,7 +5243,7 @@ Index * external archiving: Moving subtrees. (line 6) * external links: External links. (line 6) * external links, in HTML export: HTML export. (line 35) -* FAQ: Summary. (line 41) +* FAQ: Summary. (line 51) * feedback: Feedback. (line 6) * file links: External links. (line 6) * file links, searching: Search options. (line 6) @@ -5215,6 +5287,7 @@ Index * hyperlinks: Hyperlinks. (line 6) * iCalendar export: iCalendar export. (line 6) * in-buffer settings: In-buffer settings. (line 6) +* inactive timestamp: Time stamps. (line 24) * index, of published pages: Project page index. (line 6) * Info links: External links. (line 6) * inheritance, of tags: Tag inheritance. (line 6) @@ -5310,13 +5383,13 @@ Index * region, active <2>: ASCII export. (line 9) * region, active <3>: Built-in table editor. (line 165) -* region, active: Structure editing. (line 51) +* region, active: Structure editing. (line 54) * remember.el <1>: Cooperation. (line 33) * remember.el: Remember. (line 6) * remote editing, from agenda: Agenda commands. (line 100) * richer text: Enhancing text. (line 6) * RMAIL links: External links. (line 6) -* SCHEDULED keyword: Time stamps. (line 30) +* SCHEDULED keyword: Time stamps. (line 40) * scheduling: Time stamps. (line 6) * search option in file links: Search options. (line 6) * search strings, custom: Custom searches. (line 6) @@ -5379,6 +5452,7 @@ Index * TeX-like syntax for sub- and superscripts: Export options. (line 25) * thanks: History and Acknowledgments. (line 6) +* time format, custom: Custom time format. (line 6) * time grid: Time-of-day specifications. (line 26) * time stamps <1>: Time stamps. (line 6) @@ -5389,8 +5463,9 @@ Index (line 6) * time-sorted view: Timeline. (line 6) * timeline, single file: Timeline. (line 6) -* timerange: Time stamps. (line 21) -* timestamp: Time stamps. (line 13) +* timerange: Time stamps. (line 31) +* timestamp: Time stamps. (line 14) +* timestamp, inactive: Time stamps. (line 24) * timestamps, creating: Creating timestamps. (line 6) * TODO items: TODO items. (line 6) * TODO keyword matching: Global TODO list. (line 17) @@ -5403,7 +5478,7 @@ Index * transient-mark-mode <2>: ASCII export. (line 9) * transient-mark-mode <3>: Built-in table editor. (line 165) -* transient-mark-mode: Structure editing. (line 51) +* transient-mark-mode: Structure editing. (line 54) * trees, sparse: Sparse trees. (line 6) * trees, visibility: Visibility cycling. (line 6) * tty keybindings: TTY keys. (line 6) @@ -5561,7 +5636,7 @@ Key Index (line 119) * C-c C-s <1>: Agenda commands. (line 136) * C-c C-s: Creating timestamps. (line 48) -* C-c C-t <1>: Clocking work time. (line 25) +* C-c C-t <1>: Clocking work time. (line 26) * C-c C-t: TODO basics. (line 13) * C-c C-u: Motion. (line 18) * C-c C-v: TODO basics. (line 26) @@ -5569,25 +5644,26 @@ Key Index * C-c C-x C-a: ARCHIVE tag. (line 28) * C-c C-x C-b: Checkboxes. (line 38) * C-c C-x C-c: Agenda commands. (line 201) -* C-c C-x C-d: Clocking work time. (line 33) +* C-c C-x C-d: Clocking work time. (line 34) * C-c C-x C-i: Clocking work time. (line 12) -* C-c C-x C-k: Structure editing. (line 36) +* C-c C-x C-k: Structure editing. (line 39) * C-c C-x C-l: Processing LaTeX fragments. (line 9) * C-c C-x C-o: Clocking work time. (line 14) -* C-c C-x C-r: Clocking work time. (line 40) +* C-c C-x C-r: Clocking work time. (line 42) +* C-c C-x C-t: Custom time format. (line 12) * C-c C-x C-u: Dynamic blocks. (line 21) * C-c C-x C-w <1>: Built-in table editor. (line 108) -* C-c C-x C-w: Structure editing. (line 36) -* C-c C-x C-x: Clocking work time. (line 29) +* C-c C-x C-w: Structure editing. (line 39) +* C-c C-x C-x: Clocking work time. (line 30) * C-c C-x C-y <1>: Built-in table editor. (line 112) -* C-c C-x C-y: Structure editing. (line 43) +* C-c C-x C-y: Structure editing. (line 46) * C-c C-x M-w <1>: Built-in table editor. (line 105) -* C-c C-x M-w: Structure editing. (line 40) -* C-c C-y <1>: Clocking work time. (line 20) +* C-c C-x M-w: Structure editing. (line 43) +* C-c C-y <1>: Clocking work time. (line 21) * C-c C-y: Creating timestamps. (line 66) * C-c l: Handling links. (line 9) * C-c {: CDLaTeX mode. (line 21) @@ -5602,7 +5678,7 @@ Key Index * C-u C-c C-l: Handling links. (line 43) * C-u C-c C-x C-a: ARCHIVE tag. (line 31) * C-u C-c C-x C-u <1>: Dynamic blocks. (line 22) -* C-u C-c C-x C-u: Clocking work time. (line 67) +* C-u C-c C-x C-u: Clocking work time. (line 69) * D: Agenda commands. (line 68) * d: Agenda commands. (line 65) * f: Agenda commands. (line 44) @@ -5617,12 +5693,12 @@ Key Index (line 82) * M- <1>: Built-in table editor. (line 72) -* M-: Structure editing. (line 18) +* M-: Structure editing. (line 21) * M- <1>: Plain lists. (line 42) * M-: Structure editing. (line 6) * M- <1>: Built-in table editor. (line 72) -* M-: Structure editing. (line 21) +* M-: Structure editing. (line 24) * M- <1>: Completion. (line 10) * M- <2>: Setting tags. (line 6) * M-: Per file keywords. (line 17) @@ -5631,26 +5707,26 @@ Key Index * M-S- <1>: Built-in table editor. (line 89) * M-S- <2>: Plain lists. (line 59) -* M-S-: Structure editing. (line 33) +* M-S-: Structure editing. (line 36) * M-S- <1>: The date/time prompt. (line 50) * M-S- <2>: Built-in table editor. (line 76) * M-S- <3>: Plain lists. (line 65) -* M-S-: Structure editing. (line 24) +* M-S-: Structure editing. (line 27) * M-S- <1>: Checkboxes. (line 52) * M-S- <2>: Plain lists. (line 52) -* M-S-: Structure editing. (line 15) +* M-S-: Structure editing. (line 18) * M-S- <1>: The date/time prompt. (line 47) * M-S- <2>: Built-in table editor. (line 79) * M-S- <3>: Plain lists. (line 65) -* M-S-: Structure editing. (line 27) +* M-S-: Structure editing. (line 30) * M-S- <1>: Built-in table editor. (line 86) * M-S- <2>: Plain lists. (line 59) -* M-S-: Structure editing. (line 30) +* M-S-: Structure editing. (line 33) * mouse-1 <1>: Agenda commands. (line 35) * mouse-1 <2>: The date/time prompt. (line 32) @@ -5706,153 +5782,155 @@ Key Index  Tag Table: Node: Top964 -Node: Introduction10239 -Node: Summary10654 -Node: Installation12921 -Node: Activation14299 -Node: Feedback15548 -Node: Document structure16317 -Node: Outlines17091 -Node: Headlines17751 -Node: Visibility cycling18374 -Ref: Visibility cycling-Footnote-119849 -Ref: Visibility cycling-Footnote-219907 -Node: Motion19957 -Node: Structure editing20741 -Node: Archiving22850 -Node: ARCHIVE tag23408 -Node: Moving subtrees25201 -Node: Sparse trees26242 -Ref: Sparse trees-Footnote-128373 -Ref: Sparse trees-Footnote-228465 -Node: Plain lists28580 -Ref: Plain lists-Footnote-132105 -Ref: Plain lists-Footnote-232462 -Node: Tables32644 -Node: Built-in table editor33192 -Node: Narrow columns40800 -Ref: Narrow columns-Footnote-142739 -Node: Table calculations42785 -Node: Formula syntax44105 -Ref: Formula syntax-Footnote-147010 -Node: Lisp formulas47310 -Node: Column formulas48099 -Node: Advanced features49861 -Node: Named-field formulas53115 -Node: Editing/debugging formulas53755 -Node: Appetizer55513 -Node: orgtbl-mode56616 -Node: table.el57107 -Node: Hyperlinks58084 -Node: Link format58857 -Node: Internal links60150 -Ref: Internal links-Footnote-162139 -Node: Radio targets62271 -Node: CamelCase links62986 -Node: External links63580 -Node: Handling links65711 -Ref: Handling links-Footnote-170363 -Ref: Handling links-Footnote-270600 -Node: Link abbreviations70674 -Node: Search options72353 -Ref: Search options-Footnote-174131 -Node: Custom searches74212 -Node: Remember75260 -Node: TODO items78950 -Node: TODO basics79932 -Node: TODO extensions81459 -Node: Workflow states82254 -Node: TODO types83122 -Ref: TODO types-Footnote-184780 -Node: Per file keywords84862 -Ref: Per file keywords-Footnote-186316 -Node: Priorities86517 -Node: Breaking down tasks87761 -Ref: Breaking down tasks-Footnote-188281 -Node: Checkboxes88377 -Node: Timestamps91113 -Node: Time stamps91503 -Node: Creating timestamps94600 -Node: The date/time prompt97143 -Ref: The date/time prompt-Footnote-198827 -Node: Progress logging98933 -Node: Closing items99463 -Node: Clocking work time100367 -Ref: Clocking work time-Footnote-1103930 -Node: Tags104056 -Node: Tag inheritance104818 -Node: Setting tags105755 -Ref: Setting tags-Footnote-1109271 -Ref: Setting tags-Footnote-2109383 -Node: Tag searches109463 -Node: Agenda views111474 -Node: Agenda files113567 -Ref: Agenda files-Footnote-1114527 -Ref: Agenda files-Footnote-2114676 -Node: Agenda dispatcher114869 -Node: Weekly/Daily agenda116486 -Node: Calendar/Diary integration117451 -Node: Global TODO list118789 -Node: Matching headline tags120949 -Node: Timeline122007 -Node: Presentation and sorting122670 -Node: Categories123448 -Node: Time-of-day specifications124112 -Node: Sorting of agenda items126090 -Node: Agenda commands127372 -Node: Custom agenda views133260 -Node: Storing searches133935 -Node: Block agenda135847 -Node: Setting Options137077 -Node: Batch processing139789 -Node: Embedded LaTeX140919 -Ref: Embedded LaTeX-Footnote-1142011 -Node: Math symbols142201 -Node: Subscripts and Superscripts142966 -Node: LaTeX fragments143810 -Ref: LaTeX fragments-Footnote-1145918 -Node: Processing LaTeX fragments146180 -Node: CDLaTeX mode147126 -Ref: CDLaTeX mode-Footnote-1149610 -Node: Exporting149758 -Node: ASCII export151072 -Node: HTML export152362 -Node: XOXO export155198 -Node: iCalendar export155637 -Node: Text interpretation157460 -Node: Comment lines157939 -Node: Enhancing text158410 -Node: Export options160102 -Node: Publishing161769 -Ref: Publishing-Footnote-1162565 -Node: Configuration162761 -Node: Project alist163479 -Node: Sources and destinations164545 -Node: Selecting files165275 -Node: Publishing action166023 -Node: Publishing options167256 -Node: Publishing links169408 -Node: Project page index170921 -Node: Sample configuration171699 -Node: Simple example172191 -Node: Complex example172864 -Node: Triggering publication174940 -Node: Miscellaneous175625 -Node: Completion176259 -Node: Customization177730 -Node: In-buffer settings178315 -Node: The very busy C-c C-c key181736 -Node: Clean view183380 -Node: TTY keys185957 -Node: Interaction187566 -Node: Cooperation187963 -Node: Conflicts189830 -Node: Bugs191422 -Node: Extensions and Hacking193045 -Node: Extensions193531 -Node: Dynamic blocks195101 -Node: History and Acknowledgments197028 -Node: Index202036 -Node: Key Index228686 +Node: Introduction10362 +Node: Summary10777 +Node: Installation13689 +Node: Activation15067 +Node: Feedback16316 +Node: Document structure17085 +Node: Outlines17859 +Node: Headlines18519 +Node: Visibility cycling19142 +Ref: Visibility cycling-Footnote-120617 +Ref: Visibility cycling-Footnote-220675 +Node: Motion20725 +Node: Structure editing21509 +Node: Archiving23825 +Node: ARCHIVE tag24383 +Node: Moving subtrees26176 +Node: Sparse trees27217 +Ref: Sparse trees-Footnote-129348 +Ref: Sparse trees-Footnote-229440 +Node: Plain lists29555 +Ref: Plain lists-Footnote-133080 +Ref: Plain lists-Footnote-233437 +Node: Tables33619 +Node: Built-in table editor34167 +Node: Narrow columns41775 +Ref: Narrow columns-Footnote-143714 +Node: Table calculations43760 +Node: Formula syntax45080 +Ref: Formula syntax-Footnote-147985 +Node: Lisp formulas48285 +Node: Column formulas49074 +Node: Advanced features50836 +Node: Named-field formulas54090 +Node: Editing/debugging formulas54730 +Node: Appetizer56488 +Node: orgtbl-mode57591 +Node: table.el58082 +Node: Hyperlinks59059 +Node: Link format59832 +Node: Internal links61125 +Ref: Internal links-Footnote-163114 +Node: Radio targets63246 +Node: CamelCase links63961 +Node: External links64555 +Node: Handling links66686 +Ref: Handling links-Footnote-171338 +Ref: Handling links-Footnote-271575 +Node: Link abbreviations71649 +Node: Search options73328 +Ref: Search options-Footnote-175106 +Node: Custom searches75187 +Node: Remember76235 +Node: TODO items79925 +Node: TODO basics80907 +Node: TODO extensions82434 +Node: Workflow states83229 +Node: TODO types84097 +Ref: TODO types-Footnote-185755 +Node: Per file keywords85837 +Ref: Per file keywords-Footnote-187291 +Node: Priorities87492 +Node: Breaking down tasks88736 +Ref: Breaking down tasks-Footnote-189256 +Node: Checkboxes89352 +Node: Timestamps92088 +Node: Time stamps92549 +Ref: Time stamps-Footnote-196038 +Node: Creating timestamps96154 +Node: The date/time prompt98779 +Ref: The date/time prompt-Footnote-1100472 +Node: Custom time format100578 +Node: Progress logging102137 +Node: Closing items102666 +Node: Clocking work time103570 +Ref: Clocking work time-Footnote-1107196 +Node: Tags107322 +Node: Tag inheritance108084 +Node: Setting tags109021 +Ref: Setting tags-Footnote-1112537 +Ref: Setting tags-Footnote-2112649 +Node: Tag searches112729 +Node: Agenda views114729 +Node: Agenda files116822 +Ref: Agenda files-Footnote-1117782 +Ref: Agenda files-Footnote-2117931 +Node: Agenda dispatcher118124 +Node: Weekly/Daily agenda119741 +Node: Calendar/Diary integration120706 +Node: Global TODO list122044 +Node: Matching headline tags124204 +Node: Timeline125262 +Node: Presentation and sorting125925 +Node: Categories126703 +Node: Time-of-day specifications127367 +Node: Sorting of agenda items129345 +Node: Agenda commands130627 +Node: Custom agenda views136515 +Node: Storing searches137190 +Node: Block agenda139102 +Node: Setting Options140332 +Node: Batch processing143044 +Node: Embedded LaTeX144174 +Ref: Embedded LaTeX-Footnote-1145266 +Node: Math symbols145456 +Node: Subscripts and Superscripts146221 +Node: LaTeX fragments147065 +Ref: LaTeX fragments-Footnote-1149173 +Node: Processing LaTeX fragments149435 +Node: CDLaTeX mode150381 +Ref: CDLaTeX mode-Footnote-1152865 +Node: Exporting153013 +Node: ASCII export154327 +Node: HTML export155617 +Node: XOXO export158453 +Node: iCalendar export158892 +Node: Text interpretation160715 +Node: Comment lines161194 +Node: Enhancing text161665 +Node: Export options163357 +Node: Publishing165024 +Ref: Publishing-Footnote-1165820 +Node: Configuration166016 +Node: Project alist166734 +Node: Sources and destinations167800 +Node: Selecting files168530 +Node: Publishing action169278 +Node: Publishing options170511 +Node: Publishing links172663 +Node: Project page index174176 +Node: Sample configuration174954 +Node: Simple example175446 +Node: Complex example176119 +Node: Triggering publication178195 +Node: Miscellaneous178880 +Node: Completion179514 +Node: Customization180985 +Node: In-buffer settings181570 +Node: The very busy C-c C-c key185190 +Node: Clean view186834 +Node: TTY keys189411 +Node: Interaction191020 +Node: Cooperation191417 +Node: Conflicts193284 +Node: Bugs194876 +Node: Extensions and Hacking196499 +Node: Extensions196985 +Node: Dynamic blocks198555 +Node: History and Acknowledgments200482 +Node: Index205490 +Node: Key Index232505  End Tag Table diff --git a/org-install.el b/org-install.el index 15ad9fc2e..bb6441e0d 100644 --- a/org-install.el +++ b/org-install.el @@ -8,7 +8,8 @@ (autoload 'turn-on-orgtbl "org" "Org tables as a minor mode.") (autoload 'org-cycle "org" "Subtree visibility cycling." t) (autoload 'org-global-cycle "org" "Global visibility cycling." t) -(autoload 'org-agenda-list "org" "Produce calendar-loke agenda view." t) +(autoload 'org-agenda-list "org" "Produce calendar-like agenda view." t) +(autoload 'org-cycle-agenda-files "org" "Cycle through agenda-files." t) (autoload 'org-todo-list "org" "Produce global TODO list." t) (autoload 'org-tags-view "org" "Produce global TAGS agenda view." t) (autoload 'org-remember-annotation "org") diff --git a/org-mouse.el b/org-mouse.el new file mode 100644 index 000000000..242495e78 --- /dev/null +++ b/org-mouse.el @@ -0,0 +1,860 @@ +;;; org-mouse.el --- Better mouse support for org-mode + +;; Copyright (c) 2006 Piotr Zielinski +;; +;; Author: Piotr Zielinski +;; Version: 0.18 +;; $Id: org-mouse.el 254 2006-10-26 21:15:52Z pz215 $ +;; +;; The latest version of this file is available from +;; +;; http://www.cl.cam.ac.uk/~pz215/files/org-mouse.el +;; +;; This file is *NOT* part of GNU Emacs. +;; This file is distributed under the same terms as GNU Emacs. + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as +;; published by the Free Software Foundation; either version 2 of +;; the License, or (at your option) any later version. + +;; This program is distributed in the hope that it will be +;; useful, but WITHOUT ANY WARRANTY; without even the implied +;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +;; PURPOSE. See the GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public +;; License along with this program; if not, write to the Free +;; Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, +;; MA 02111-1307 USA + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;;; Commentary: +;; +;; Org-mouse provides better mouse support for org-mode. Org-mode is +;; a mode for keeping notes, maintaining ToDo lists, and doing project +;; planning with a fast and effective plain-text system. It is +;; available from +;; +;; http://staff.science.uva.nl/~dominik/Tools/org/ +;; +;; Org-mouse implements the following features: +;; * following links with the left mouse button (in Emacs 22) +;; * subtree expansion/collapse (org-cycle) with the left mouse button +;; * several context menus on the right mouse button: +;; + general text +;; + headlines +;; + timestamps +;; + priorities +;; + links +;; + tags +;; * promoting/demoting/moving subtrees with mouse-3 +;; + if the drag starts and ends in the same line then promote/demote +;; + otherwise move the subtree +;; * date/time extraction from selected text (requires a python script) +;; (eg. select text from your email and click "Add Appointment") +;; +;; The python script that automatically extracts date/time information +;; from a piece of English text is available from: +;; +;; http://www.cl.cam.ac.uk/~pz215/files/timeparser.py +;; +;; Use +;; ------------ +;; +;; To use this package, put the following line in your .emacs: +;; +;; (require 'org-mouse) +;; +;; Tested with Emacs 22.0.50, org-mode 4.33 + +;; Fixme: +;; + deal with folding / unfolding issues + +;; TODO (This list is only theoretical, if you'd like to have some +;; feature implemented or a bug fix please send me an email, even if +;; something similar appears in the list below. This will help me get +;; the priorities right.): + +;; + The "New Appointment" menu entry seems out of place. Remove it +;; and enhance the time/data selection function so that if the text +;; in the clipboard contains a date/time, then set that date as the +;; default (instead of "today") + +;; + org-store-link, insert link +;; + org tables +;; + occur with the current word/tag (same menu item) +;; + ctrl-c ctrl-c, for example, renumber the current list +;; + internal links + +;; Please email me with new feature suggestions / bugs + +;; History: +;; +;; Version 0.19 +;; + added support for dragging URLs to the org-buffer +;; +;; Version 0.18 +;; + added support for agenda blocks +;; +;; Version 0.17 +;; + toggle checkboxes with a single click +;; +;; Version 0.16 +;; + added support for checkboxes +;; +;; Version 0.15 +;; + org-mode now works with the Agenda buffer as well +;; +;; Version 0.14 +;; + added a menu option that converts plain list items to outline items +;; +;; Version 0.13 +;; + "Insert Heading" now inserts a sibling heading if the point is +;; on "***" and a child heading otherwise +;; +;; Version 0.12 +;; + compatible with Emacs 21 +;; + custom agenda commands added to the main menu +;; + moving trees should now work between windows in the same frame +;; +;; Version 0.11 +;; + fixed org-mouse-at-link (thanks to Carsten) +;; + removed [follow-link] bindings +;; +;; Version 0.10 +;; + added a menu option to remove highlights +;; + compatible with org-mode 4.21 now +;; +;; Version 0.08: +;; + trees can be moved/promoted/demoted by dragging with the right +;; mouse button (mouse-3) +;; + small changes in the above function +;; +;; Versions 0.01 -- 0.07: (I don't remember) + +(eval-when-compile (require 'cl)) + +(defvar org-mouse-plain-list-regexp "\\([ \t]*\\)\\([-+*]\\|[0-9]+[.)]\\) ") +(defvar org-mouse-direct t) + +(defgroup org-mouse nil + "Org-mouse" + :tag "Org Mouse." + :group 'org) + +(defcustom org-mouse-punctuation ":" + "" + :group 'org-mouse + :type 'string) + + +(defun org-mouse-re-search-line (regexp) + "Searches the current line for a given regular expression." + (beginning-of-line) + (re-search-forward regexp (point-at-eol) t)) + +(defun org-mouse-end-headline () + "Go to the end of current headline (ignoring tags)." + (interactive) + (end-of-line) + (skip-chars-backward "\t ") + (when (looking-back ":[A-Za-z]+:") + (skip-chars-backward ":A-Za-z") + (skip-chars-backward "\t "))) + + +(defun org-mouse-show-context-menu (event prefix) + (interactive "@e \nP") + (if (and (= (event-click-count event) 1) + (or (not mark-active) + (sit-for (/ double-click-time 1000.0)))) + (progn + (select-window (posn-window (event-start event))) + (goto-char (posn-point (event-start event))) + (when (not (eolp)) (save-excursion (run-hooks 'post-command-hook))) + (let ((redisplay-dont-pause t)) + (sit-for 0)) + (if (functionp org-mouse-context-menu-function) + (funcall org-mouse-context-menu-function) + (mouse-major-mode-menu event prefix)) + ) + (setq this-command 'mouse-save-then-kill) + (mouse-save-then-kill event))) + + +(defun org-mouse-line-position () + "Returns :beginning :middle :end" + (cond + ((eolp) :end) + ((org-mouse-bolp) :begin) + (t :middle))) + +(defun org-mouse-empty-line () + (save-excursion (beginning-of-line) (looking-at "[ \t]*$"))) + +(defun org-mouse-next-heading () + "Goes to the next heading and if there is none, it ensures that the point is at the beginning of an empty line." + (unless (outline-next-heading) + (beginning-of-line) + (unless (org-mouse-empty-line) + (end-of-line) + (newline)))) + +(defun org-mouse-insert-heading () + (interactive) + (case (org-mouse-line-position) + (:begin (beginning-of-line) + (org-insert-heading)) + (t (org-mouse-next-heading) + (org-insert-heading)))) + +(defun org-mouse-timestamp-today (&optional shift units) + (interactive) + (flet ((org-read-date (x &optional y) (current-time))) + (org-time-stamp nil)) + (when shift + (org-timestamp-change shift units))) + +(defun org-mouse-keyword-menu (keywords function &optional selected itemformat) + (mapcar + (lambda (keyword) + (vector (cond + ((functionp itemformat) (funcall itemformat keyword)) + ((stringp itemformat) (format itemformat keyword)) + (t keyword)) + `(funcall ,function ,keyword) + :style (cond + ((null selected) t) + ((functionp selected) 'toggle) + (t 'radio)) + :selected `(if (functionp ,selected) + (funcall ,selected ,keyword) + (equal ,selected ,keyword)))) + keywords)) + +(defun org-mouse-remove-match-and-spaces () + (interactive) + (replace-match "") + (when (looking-at " +") + (replace-match ""))) + + +(defun org-mouse-keyword-replace-menu (keywords &optional group itemformat) + (setq group (or group 0)) + (append + (org-mouse-keyword-menu + keywords + `(lambda (keyword) (replace-match keyword t t nil ,group)) + `(match-string ,group) + itemformat) + '(["None" org-mouse-remove-match-and-spaces t]))) + +(defvar org-mouse-context-menu-function nil) +(make-variable-buffer-local 'org-mouse-context-menu-function) + +(defun org-mouse-show-headlines () + (interactive) + (let ((this-command 'org-cycle) + (last-command 'org-cycle) + (org-cycle-global-status nil)) + (org-cycle '(4)) + (org-cycle '(4)))) + +(defun org-mouse-show-overview () + (interactive) + (let ((org-cycle-global-status nil)) + (org-cycle '(4)))) + +(defun org-mouse-set-priority (priority) + (flet ((read-char-exclusive () priority)) + (org-priority))) + +(defvar org-mouse-priority-regexp "\\[#\\([A-Z]\\)\\]" + "Regular expression matching the priority indicator. Differs from `org-priority-regexp' in that it doesn't contain the leading '.*?'.") + + +(defun org-mouse-get-priority (&optional default) + (save-excursion + (if (org-mouse-re-search-line org-mouse-priority-regexp) + (match-string 1) + (when default (char-to-string org-default-priority))))) + +(defun org-mouse-at-link () + (and (eq (get-text-property (point) 'face) 'org-link) + (save-excursion + (goto-char (previous-single-property-change (point) 'face)) + (or (looking-at org-bracket-link-regexp) + (looking-at org-angle-link-re) + (looking-at org-plain-link-re))))) + + +(defun org-mouse-delete-timestamp () + "Deletes the current timestamp as well as the preceding +SCHEDULED: or DEADLINE: or ANYTHINGLIKETHIS:" + (when (or (org-at-date-range-p) (org-at-timestamp-p)) + (replace-match "") ; delete the timestamp + (skip-chars-backward " :A-Z") + (when (looking-at " *[A-Z][A-Z]+:") + (replace-match "")))) + +(defun org-mouse-looking-at (regexp skipchars &optional movechars) + (save-excursion + (let ((point (point))) + (if (looking-at regexp) t + (skip-chars-backward skipchars) + (forward-char (or movechars 0)) + (when (looking-at regexp) + (> (match-end 0) point)))))) + + +(defun org-mouse-priority-list () + (let ((ret) (current org-lowest-priority)) + (while (>= current ?A) + (push (char-to-string current) ret) + (decf current)) + ret)) + +(defun org-mouse-tag-menu () ;todo + (append + (let ((tags (org-split-string (org-get-tags) ":"))) + (org-mouse-keyword-menu + (sort (mapcar 'car (org-get-buffer-tags)) 'string-lessp) + `(lambda (tag) + (org-mouse-set-tags + (sort (if (member tag (quote ,tags)) + (delete tag (quote ,tags)) + (cons tag (quote ,tags))) + 'string-lessp))) + `(lambda (tag) (member tag (quote ,tags))) + )) + '("--" + ["Align Tags Here" (org-set-tags nil t) t] + ["Align Tags in Buffer" (org-set-tags t t) t] + ["Set Tags ..." (org-set-tags) t]))) + + + +(defun org-mouse-set-tags (tags) + (save-excursion + ;; remove existing tags first + (beginning-of-line) + (when (org-mouse-re-search-line ":\\(\\([A-Za-z_]+:\\)+\\)") + (replace-match "")) + + ;; set new tags if any + (when tags + (end-of-line) + (insert " :" (mapconcat 'identity tags ":") ":") + (org-set-tags nil t)))) + +(defun org-mouse-insert-checkbox () + (interactive) + (and (org-at-item-p) + (goto-char (match-end 0)) + (unless (org-at-item-checkbox-p) + (delete-horizontal-space) + (insert " [ ] ")))) + +(defun org-mouse-agenda-type (type) + (case type + ('tags "Tags: ") + ('todo "TODO: ") + ('tags-tree "Tags tree: ") + ('todo-tree "TODO tree: ") + ('occur-tree "Occur tree: ") + (t "Agenda command ???"))) + + +(defun org-mouse-clip-text (text maxlength) + (if (> (length text) maxlength) + (concat (substring text 0 (- maxlength 3)) "...") + text)) + +(defun org-mouse-popup-global-menu () + (popup-menu + `("Main Menu" + ["Show Overview" org-mouse-show-overview t] + ["Show Headlines" org-mouse-show-headlines t] + ["Show All" show-all t] + ["Remove Highlights" org-remove-occur-highlights + :visible org-occur-highlights] + "--" + ["Check Deadlines" + (if (functionp 'org-check-deadlines-and-todos) + (org-check-deadlines-and-todos org-deadline-warning-days) + (org-check-deadlines org-deadline-warning-days)) t] + ["Check TODOs" org-show-todo-tree t] + ("Check Tags" + ,@(org-mouse-keyword-menu + (sort (mapcar 'car (org-get-buffer-tags)) 'string-lessp) + '(lambda (tag) (org-tags-sparse-tree nil tag))) + "--" + ["Custom Tag ..." org-tags-sparse-tree t]) + ["Check Phrase ..." org-occur] + "--" + ["Display Agenda" org-agenda-list t] + ["Display Timeline" org-timeline t] + ["Display TODO List" org-todo-list t] + ("Display Tags" + ,@(org-mouse-keyword-menu + (sort (mapcar 'car (org-get-buffer-tags)) 'string-lessp) + '(lambda (tag) (org-tags-view nil tag))) + "--" + ["Custom Tag ..." org-tags-view t]) + ["Display Calendar" org-goto-calendar t] + "--" +;; ("Custom Commands" +;; ,@(org-mouse-keyword-menu +;; (mapcar 'car org-agenda-custom-commands) +;; '(lambda (key) +;; (eval `(flet ((read-char-exclusive () (string-to-char ,key))) +;; (let ((current-prefix-arg t)) +;; (org-agenda nil))))) +;; nil "Agenda (TODO) '%s'") +;; "--" + ,@(org-mouse-keyword-menu + (mapcar 'car org-agenda-custom-commands) + '(lambda (key) + (eval `(flet ((read-char-exclusive () (string-to-char ,key))) + (org-agenda nil)))) + nil + '(lambda (key) + (let ((entry (assoc key org-agenda-custom-commands))) + (org-mouse-clip-text + (cond + ((stringp (nth 1 entry)) (nth 1 entry)) + ((stringp (nth 2 entry)) + (concat (org-mouse-agenda-type (nth 1 entry)) + (nth 2 entry))) + (t "Agenda Command '%s'")) + 30)))) +;; ) + "--" + ["Delete Blank Lines" delete-blank-lines + :visible (org-mouse-empty-line)] + ["Insert Checkbox" org-mouse-insert-checkbox + :visible (and (org-at-item-p) (not (org-at-item-checkbox-p)))] + ["Insert Checkboxes" + (org-mouse-for-each-item 'org-mouse-insert-checkbox) + :visible (and (org-at-item-p) (not (org-at-item-checkbox-p)))] + ["Plain List to Outline" org-mouse-transform-to-outline + :visible (org-at-item-p)]))) + + +; ["Jump" org-goto]))) + +(defun org-mouse-get-context (contextlist context) + (let ((contextdata (find-if (lambda (x) (eq (car x) context)) contextlist))) + (when contextdata + (save-excursion + (goto-char (nth 1 contextdata)) +; (looking-at regexp))))) + (re-search-forward ".*" (nth 2 contextdata)))))) + +(defun org-mouse-for-each-item (function) + (save-excursion + (ignore-errors + (while t (org-previous-item))) + (ignore-errors + (while t + (funcall function) + (org-next-item))))) + +(defun org-mouse-bolp () + "Returns true if there only spaces, tabs, and '*', between the beginning of line and the point" + (save-excursion + (skip-chars-backward " \t*") (bolp))) + + +(defadvice dnd-insert-text (around org-mouse-dnd-insert-text activate) + (if (eq major-mode 'org-mode) + (case (org-mouse-line-position) + (:begin ; insert before + (beginning-of-line) + (looking-at "[ \t]*") + (open-line 1) + (indent-to (- (match-end 0) (match-beginning 0))) + (insert "+ ")) + + (:middle ; insert after + (end-of-line) + (newline t) + (indent-relative) + (insert "+ ")) + + (:end ; insert text here + (skip-chars-backward " \t") + (kill-region (point) (point-at-eol)) + (unless (looking-back org-mouse-punctuation) + (insert (concat org-mouse-punctuation " ")))) + + (insert text) + (beginning-of-line)) + ad-do-it)) + +(defun org-mouse-context-menu () + (let ((stamp-prefixes (list org-deadline-string org-scheduled-string)) + (contextlist (org-context))) + (flet ((get-context (context) (org-mouse-get-context contextlist context))) + (cond + ((or (eolp) + (and (looking-at " \\|\t") (looking-back " \\|\t"))) + (org-mouse-popup-global-menu)) +;; ((get-context :todo-keyword) + ((get-context :checkbox) + (popup-menu + '(nil + ["Toggle" org-toggle-checkbox t] + ["Remove" org-mouse-remove-match-and-spaces t] + "" + ["All Clear" (org-mouse-for-each-item + (lambda () + (when (save-excursion (org-at-item-checkbox-p)) + (replace-match "[ ]"))))] + ["All Set" (org-mouse-for-each-item + (lambda () + (when (save-excursion (org-at-item-checkbox-p)) + (replace-match "[X]"))))] + ["All Toggle" (org-mouse-for-each-item 'org-toggle-checkbox) t] + ["All Remove" (org-mouse-for-each-item + (lambda () + (when (save-excursion (org-at-item-checkbox-p)) + (org-mouse-remove-match-and-spaces))))] + ))) + ((and (org-mouse-looking-at "\\b\\w+" "a-zA-Z0-9_") + (member (match-string 0) org-todo-keywords)) + (popup-menu + `(nil + ,@(org-mouse-keyword-replace-menu org-todo-keywords) + "--" + ["Check TODOs" org-show-todo-tree t] + ["Display TODO List" org-todo-list t] + ))) + ((and (org-mouse-looking-at "\\b[A-Z]+:" "A-Z") + (member (match-string 0) stamp-prefixes)) + (popup-menu + `(nil + ,@(org-mouse-keyword-replace-menu stamp-prefixes) + "--" + ["Check Deadlines" org-check-deadlines t] + ))) + ((org-mouse-looking-at org-mouse-priority-regexp "[]A-Z#") ; priority + (popup-menu `(nil ,@(org-mouse-keyword-replace-menu + (org-mouse-priority-list) 1 "Priority %s")))) + ((org-mouse-at-link) + (popup-menu + '(nil + ["Open" org-open-at-point t] + ["Open in Emacs" (org-open-at-point t) t] + "--" + ["Copy link" (kill-new (match-string 0))] + ["Cut link" (kill-region (match-beginning 0) (match-end 0))] +; ["Paste file link" ((insert "file:") (yank))] + ))) + ((org-mouse-looking-at ":\\([A-Za-z0-9_]+\\):" "A-Za-z0-9_" -1) ;tags + (popup-menu + `(nil + [,(format "Display '%s'" (match-string 1)) + (org-tags-view nil ,(match-string 1))] + [,(format "Narrow to '%s'" (match-string 1)) + (org-tags-sparse-tree nil ,(match-string 1))] + "--" + ,@(org-mouse-tag-menu)))) + ((org-at-timestamp-p) + (popup-menu + '(nil + ["Show Day" org-open-at-point t] + ["Change Timestamp" org-time-stamp t] + ["Delete Timestamp" (org-mouse-delete-timestamp) t] + ["Compute Time Range" org-evaluate-time-range (org-at-date-range-p)] + "--" + ["Set for Today" org-mouse-timestamp-today] + ["Set for Tomorrow" (org-mouse-timestamp-today 1 'day)] + ["Set in 1 Week" (org-mouse-timestamp-today 7 'day)] + ["Set in 2 Weeks" (org-mouse-timestamp-today 14 'day)] + ["Set in a Month" (org-mouse-timestamp-today 1 'month)] + "--" + ["+ 1 Day" (org-timestamp-change 1 'day)] + ["+ 1 Week" (org-timestamp-change 7 'day)] + ["+ 1 Month" (org-timestamp-change 1 'month)] + "--" + ["- 1 Day" (org-timestamp-change -1 'day)] + ["- 1 Week" (org-timestamp-change -7 'day)] + ["- 1 Month" (org-timestamp-change -1 'month)]))) + ((and (assq :headline contextlist) (not (eolp))) + (let ((priority (org-mouse-get-priority t))) + (popup-menu + `("Headline Menu" + ("Tags and Priorities" + ,@(org-mouse-keyword-menu + (org-mouse-priority-list) + '(lambda (keyword) + (org-mouse-set-priority (string-to-char keyword))) + priority "Priority %s") + "--" + ,@(org-mouse-tag-menu)) + ["Show Tags" + (with-current-buffer org-mouse-main-buffer (org-agenda-show-tags)) + :visible (not org-mouse-direct)] + ["Show Priority" + (with-current-buffer org-mouse-main-buffer (org-agenda-show-priority)) + :visible (not org-mouse-direct)] + ,@(if org-mouse-direct '("--") nil) + ["New Heading" org-mouse-insert-heading :visible org-mouse-direct] +;; ["New Appointment" org-mouse-new-appointment :visible org-mouse-direct] +;; "--" + ["Cycle TODO" org-todo] + ["Set Deadline" + (progn (org-mouse-end-headline) (insert " ") (org-deadline)) + :active (not (save-excursion + (org-mouse-re-search-line org-deadline-regexp)))] + ["Schedule Task" + (progn (org-mouse-end-headline) (insert " ") (org-schedule)) + :active (not (save-excursion + (org-mouse-re-search-line org-scheduled-regexp)))] + ["Insert Timestamp" + (progn (org-mouse-end-headline) (insert " ") (org-time-stamp nil)) t] +; ["Timestamp (inactive)" org-time-stamp-inactive t] + "--" + ["Archive Subtree" org-archive-subtree] + ["Cut Subtree" org-cut-special] + ["Copy Subtree" org-copy-special] + ["Paste Subtree" org-paste-special :visible org-mouse-direct] + "--" +;; ["Promote Subtree" org-shiftmetaleft] +;; ["Demote Subtree" org-shiftmetaright] +;; ["Promote Heading" org-metaleft] +;; ["Demote Heading" org-metaright] +;; "--" + ["Move Trees" org-mouse-move-tree :active nil] + )))) + (t + (org-mouse-popup-global-menu)))))) + + + +;; (defun org-mouse-at-regexp (regexp) +;; (save-excursion +;; (let ((point (point)) +;; (bol (progn (beginning-of-line) (point))) +;; (eol (progn (end-of-line) (point)))) +;; (goto-char point) +;; (re-search-backward regexp bol 1) +;; (and (not (eolp)) +;; (progn (forward-char) +;; (re-search-forward regexp eol t)) +;; (<= (match-beginning 0) point))))) + +(defun org-mouse-in-region-p (pos) + (and mark-active (>= pos (region-beginning)) (< pos (region-end)))) + +(defun org-mouse-down-mouse (event) + (interactive "e") + (setq this-command last-command) + (unless (and transient-mark-mode + (= 1 (event-click-count event)) + (org-mouse-in-region-p (posn-point (event-start event)))) + (mouse-drag-region event))) + +(add-hook 'org-mode-hook + '(lambda () + (setq org-mouse-context-menu-function 'org-mouse-context-menu) + +; (define-key org-mouse-map [follow-link] 'mouse-face) + (define-key org-mouse-map (if (featurep 'xemacs) [button3] [mouse-3]) nil) + (define-key org-mode-map [mouse-3] 'org-mouse-show-context-menu) + (define-key org-mode-map [down-mouse-1] 'org-mouse-down-mouse) + (define-key org-mouse-map [C-drag-mouse-1] 'org-mouse-move-tree) + (define-key org-mouse-map [C-down-mouse-1] 'org-mouse-move-tree-start) + (define-key org-mouse-map [drag-mouse-3] 'org-mouse-move-tree) + (define-key org-mouse-map [down-mouse-3] 'org-mouse-move-tree-start) + + (font-lock-add-keywords nil + `((,outline-regexp + 0 `(face org-link mouse-face highlight keymap ,org-mouse-map) + 'prepend) + ("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +" + (1 `(face org-link keymap ,org-mouse-map mouse-face highlight) 'prepend)) + ("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[ X]\\]\\)" + (2 `(face bold keymap ,org-mouse-map mouse-face highlight) t))) + t) + + (defadvice org-open-at-point (around org-mouse-open-at-point activate) + (let ((context (org-context))) + (cond + ((assq :headline-stars context) (org-cycle)) + ((assq :checkbox context) (org-toggle-checkbox)) + ((assq :item-bullet context) + (let ((org-cycle-include-plain-lists t)) (org-cycle))) + (t ad-do-it)))))) + +(defun org-mouse-move-tree-start (event) + (interactive "e") + (message "Same line: promote/demote, (***):move before, (text): make a child")) + + +(defun org-mouse-make-marker (position) + (with-current-buffer (window-buffer (posn-window position)) + (copy-marker (posn-point position)))) + +(defun org-mouse-move-tree (event) + ;; todo: handle movements between different buffers + (interactive "e") + (save-excursion + (let* ((start (org-mouse-make-marker (event-start event))) + (end (org-mouse-make-marker (event-end event))) + (sbuf (marker-buffer start)) + (ebuf (marker-buffer end))) + + (when (and sbuf ebuf) + (set-buffer sbuf) + (goto-char start) + (org-back-to-heading) + (if (and (eq sbuf ebuf) + (equal + (point) + (save-excursion (goto-char end) (org-back-to-heading) (point)))) + ;; if the same line then promote/demote + (if (>= end start) (org-demote-subtree) (org-promote-subtree)) + ;; if different lines then move + (org-cut-subtree) + + (set-buffer ebuf) + (goto-char end) + (org-back-to-heading) + (when (and (eq sbuf ebuf) + (equal + (point) + (save-excursion (goto-char start) + (org-back-to-heading) (point)))) + (outline-end-of-subtree) + (end-of-line) + (if (eobp) (newline) (forward-char))) + + (when (looking-at outline-regexp) + (let ((level (- (match-end 0) (match-beginning 0)))) + (when (> end (match-end 0)) + (outline-end-of-subtree) + (end-of-line) + (if (eobp) (newline) (forward-char)) + (setq level (1+ level))) + (org-paste-subtree level) + (save-excursion + (outline-end-of-subtree) + (when (bolp) (delete-char -1)))))))))) + + +(defun org-mouse-transform-to-outline () + (interactive) + (org-back-to-heading) + (let ((minlevel 1000) + (replace-text (concat (match-string 0) "* "))) + (beginning-of-line 2) + (save-excursion + (while (not (or (eobp) (looking-at outline-regexp))) + (when (looking-at org-mouse-plain-list-regexp) + (setq minlevel (min minlevel (- (match-end 1) (match-beginning 1))))) + (forward-line))) + (while (not (or (eobp) (looking-at outline-regexp))) + (when (and (looking-at org-mouse-plain-list-regexp) + (eq minlevel (- (match-end 1) (match-beginning 1)))) + (replace-match replace-text)) + (forward-line)))) + + + +(defun org-mouse-do-remotely (command) +; (org-agenda-check-no-diary) + (when (get-text-property (point) 'org-marker) + (let* ((anticol (- (point-at-eol) (point))) + (marker (get-text-property (point) 'org-marker)) + (buffer (marker-buffer marker)) + (pos (marker-position marker)) + (hdmarker (get-text-property (point) 'org-hd-marker)) + (buffer-read-only nil) + (newhead "--- removed ---") + (org-mouse-direct nil) + (org-mouse-main-buffer (current-buffer))) + (when (eq (with-current-buffer buffer major-mode) 'org-mode) + (let ((endmarker (save-excursion + (set-buffer buffer) + (outline-end-of-subtree) + (forward-char 1) + (copy-marker (point))))) + (with-current-buffer buffer + (widen) + (goto-char pos) + (org-show-hidden-entry) + (save-excursion + (and (outline-next-heading) + (org-flag-heading nil))) ; show the next heading + (org-back-to-heading) + (setq marker (copy-marker (point))) + (goto-char (max (point-at-bol) (- (point-at-eol) anticol))) + (funcall command) + (unless (eq (marker-position marker) (marker-position endmarker)) + (setq newhead (org-get-heading)))) + + (beginning-of-line 1) + (save-excursion + (org-agenda-change-all-lines newhead hdmarker 'fixface))) + t)))) + +(defun org-mouse-agenda-context-menu () + (or (org-mouse-do-remotely 'org-mouse-context-menu) + (popup-menu + '("Agenda" + ("Agenda Files") + "--" + ["Rebuild Buffer" org-agenda-redo t] + ["New Diary Entry" + org-agenda-diary-entry (org-agenda-check-type nil 'agenda 'timeline)] + "--" + ["Goto Today" org-agenda-goto-today + (org-agenda-check-type nil 'agenda 'timeline)] + ["Display Calendar" org-agenda-goto-calendar + (org-agenda-check-type nil 'agenda 'timeline)] + ("Calendar Commands" + ["Phases of the Moon" org-agenda-phases-of-moon (org-agenda-check-type nil 'agenda 'timeline)] + ["Sunrise/Sunset" org-agenda-sunrise-sunset (org-agenda-check-type nil 'agenda 'timeline)] + ["Holidays" org-agenda-holidays (org-agenda-check-type nil 'agenda 'timeline)] + ["Convert" org-agenda-convert-date (org-agenda-check-type nil 'agenda 'timeline)] + "--" + ["Create iCalendar file" org-export-icalendar-combine-agenda-files t]) + "--" + ["Day View" org-agenda-day-view + :active (org-agenda-check-type nil 'agenda) + :style radio :selected (equal org-agenda-ndays 1)] + ["Week View" org-agenda-week-view + :active (org-agenda-check-type nil 'agenda) + :style radio :selected (equal org-agenda-ndays 7)] + "--" + ["Show Logbook entries" org-agenda-log-mode + :style toggle :selected org-agenda-show-log + :active (org-agenda-check-type nil 'agenda 'timeline)] + ["Include Diary" org-agenda-toggle-diary + :style toggle :selected org-agenda-include-diary + :active (org-agenda-check-type nil 'agenda)] + ["Use Time Grid" org-agenda-toggle-time-grid + :style toggle :selected org-agenda-use-time-grid + :active (org-agenda-check-type nil 'agenda)] + ["Follow Mode" org-agenda-follow-mode + :style toggle :selected org-agenda-follow-mode] + "--" + ["Quit" org-agenda-quit t] + ["Exit and Release Buffers" org-agenda-exit t] + )))) + + +; (setq org-agenda-mode-hook nil) +(add-hook 'org-agenda-mode-hook + '(lambda () +; (define-key org-agenda-keymap [follow-link] 'mouse-face) + (setq org-mouse-context-menu-function 'org-mouse-agenda-context-menu) + (define-key org-agenda-keymap + (if (featurep 'xemacs) [button3] [mouse-3]) 'org-mouse-show-context-menu))) + +(provide 'org-mouse) + \ No newline at end of file diff --git a/org.el b/org.el index d8eaa0ccb..3c0c21a6b 100644 --- a/org.el +++ b/org.el @@ -5,7 +5,7 @@ ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/ -;; Version: 4.52 +;; Version: 4.53 ;; ;; This file is part of GNU Emacs. ;; @@ -61,6 +61,13 @@ ;; ;; Recent changes ;; -------------- +;; Version 4.53 +;; - Custom time formats can be overlayed over time stamps. +;; - New option `org-agenda-todo-ignore-deadlines'. +;; - Work-around for flyspell bug (CVS Emacs has this fixed in flyspell.el). +;; - Work-around for session.el proglem with circular data structures. +;; - Bug fixes. +;; ;; Version 4.52 ;; - TAG matches can also specify conditions on TODO keywords. ;; - The fast tag interface allows setting tags that are not in the @@ -149,7 +156,7 @@ ;;; Customization variables -(defvar org-version "4.52" +(defvar org-version "4.53" "The version number of the file org.el.") (defun org-version () (interactive) @@ -1115,7 +1122,7 @@ rather than having to type \"yes\"." (defcustom org-confirm-elisp-link-function 'yes-or-no-p "Non-nil means, ask for confirmation before executing elisp links. -Elisp links can be dangerous, just thing about a link +Elisp links can be dangerous, just think about a link [[elisp:(shell-command \"rm -rf ~/*\")][Google Search]] @@ -1138,7 +1145,7 @@ See `org-file-apps'.") (defconst org-file-apps-defaults-macosx '((remote . emacs) - (t . "open %s") + (t . "open %s") ("ps" . "gv %s") ("ps.gz" . "gv %s") ("eps" . "gv %s") @@ -1398,9 +1405,27 @@ a double prefix argument to a time-stamp command like `C-c .' or `C-c !'." :group 'org-time :type 'integer) +(defcustom org-display-custom-times nil + "Non-nil means, overlay custom formats over all time stamps. +See also `org-time-stamp-custom-formats'. +To turn this on on a per-file basis, insert anywhere in the file: + #+STARTUP: customtime" + :group 'org-time + :set 'set-default + :type 'sexp) +(make-variable-buffer-local 'org-display-custom-times) + +(defcustom org-time-stamp-custom-formats + '("<%m/%d/%y %a>" . "<%m/%d/%y %a %H:%M>") ; american + "Custom formats for time stamps. See `format-time-string' for the syntax. +These are overlayed over the default ISO format if the variable +`org-display-custom-times' is set." + :group 'org-time + :type 'sexp) + (defcustom org-deadline-warning-days 30 "No. of days before expiration during which a deadline becomes active. -This variable governs the display in the org file." +This variable governs the display in sparse trees and in the agenda." :group 'org-time :type 'number) @@ -1530,8 +1555,7 @@ agenda file per line." (repeat :tag "List of files" file) (file :tag "Store list in a file\n" :value "~/.agenda_files"))) -(defcustom org-agenda-custom-commands ;'(("w" todo "WAITING")) -'(("w" todo "WAITING" ((aaa 1) (bbb 2)))) +(defcustom org-agenda-custom-commands '(("w" todo "WAITING")) "Custom commands for the agenda. These commands will be offered on the splash screen displayed by the agenda dispatcher \\[org-agenda]. Each entry is a list like this: @@ -1635,6 +1659,15 @@ of this item." :group 'org-todo :type 'boolean) +(defcustom org-agenda-todo-ignore-deadlines nil + "Non-nil means, don't show near deadline entries in the global todo list. +Near means closer than `org-deadline-warning-days' days. +The idea behind this is that such items will appear in the agenda anyway." + :group 'org-agenda + :group 'org-todo + :type 'boolean) + + (defcustom org-timeline-show-empty-dates 3 "Non-nil means, `org-timeline' also shows dates without an entry. When nil, only the days which actually have entries are shown. @@ -2878,7 +2911,7 @@ Also put tags into group 4 if tags are present.") (make-variable-buffer-local 'org-keyword-time-regexp) (defconst org-rm-props '(invisible t face t keymap t intangible t mouse-face t - mouse-map t) + rear-nonsticky t mouse-map t) "Properties to remove when a string without properties is wanted.") (defsubst org-match-string-no-properties (num &optional string) @@ -2930,6 +2963,7 @@ Also put tags into group 4 if tags are present.") ("oddeven" org-odd-levels-only nil) ("align" org-startup-align-all-tables t) ("noalign" org-startup-align-all-tables nil) + ("customtime" org-display-custom-times t) ("logging" org-log-done t) ("nologging" org-log-done nil) ("dlcheck" org-startup-with-deadline-check t) @@ -2942,7 +2976,7 @@ Also put tags into group 4 if tags are present.") '("CATEGORY" "SEQ_TODO" "PRI_TODO" "TYP_TODO" "STARTUP" "ARCHIVE" "TAGS" "LINK"))) (splitre "[ \t]+") - kwds int key value cat arch tags links tmp) + kwds int key value cat arch tags links) (save-excursion (save-restriction (widen) @@ -3112,11 +3146,8 @@ Also put tags into group 4 if tags are present.") ;;; Define the mode -(defvar org-mode-map - (if (and (not (keymapp outline-mode-map)) (featurep 'allout)) - (error "Conflict with outdated version of allout.el. Load org.el before allout.el, or ugrade to newer allout, for example by switching to Emacs 22.") - (copy-keymap outline-mode-map)) - "Keymap for Org-mode.") +(if (and (not (keymapp outline-mode-map)) (featurep 'allout)) + (error "Conflict with outdated version of allout.el. Load org.el before allout.el, or ugrade to newer allout, for example by switching to Emacs 22.")) (defvar org-struct-menu) ; defined later in this file (defvar org-org-menu) ; defined later in this file @@ -3128,6 +3159,7 @@ Also put tags into group 4 if tags are present.") "Indicates that a table might need an update. This variable is set by `org-before-change-function'. `org-table-align' sets it back to nil.") +(defvar org-mode-map) (defvar org-mode-hook nil) (defvar org-inhibit-startup nil) ; Dynamically-scoped param. (defvar org-agenda-keep-modes nil) ; Dynamically-scoped param. @@ -3155,7 +3187,8 @@ The following commands are available: ;; Get rid of Outline menus, they are not needed ;; Need to do this here because define-derived-mode sets up - ;; the keymap so late. + ;; the keymap so late. Still, it is a waste to call this each time + ;; we switch another buffer into org-mode. (if (featurep 'xemacs) (progn ;; Assume this is Greg's port, it used easymenu @@ -3313,7 +3346,6 @@ that will be added to PLIST. Returns the string that was modified." ; 4: [desc] ; 5: desc - (defconst org-ts-lengths (cons (length (format-time-string (car org-time-stamp-formats))) (length (format-time-string (cdr org-time-stamp-formats)))) @@ -3330,9 +3362,16 @@ that will be added to PLIST. Returns the string that was modified." "Regular expression matching time stamps (also [..]), with groups.") (defconst org-tr-regexp (concat org-ts-regexp "--?-?" org-ts-regexp) "Regular expression matching a time stamp range.") +(defconst org-tr-regexp-both + (concat org-ts-regexp-both "--?-?" org-ts-regexp-both) + "Regular expression matching a time stamp range.") (defconst org-tsr-regexp (concat org-ts-regexp "\\(--?-?" org-ts-regexp "\\)?") "Regular expression matching a time stamp or time stamp range.") +(defconst org-tsr-regexp-both (concat org-ts-regexp-both "\\(--?-?" + org-ts-regexp-both "\\)?") + "Regular expression matching a time stamp or time stamp range. +The time stamps may be either active or inactive.") (defvar org-emph-face nil) @@ -3355,6 +3394,7 @@ that will be added to PLIST. Returns the string that was modified." (progn (add-text-properties (match-beginning 0) (match-end 0) (list 'mouse-face 'highlight + 'rear-nonsticky t 'keymap org-mouse-map )) t))) @@ -3365,10 +3405,23 @@ that will be added to PLIST. Returns the string that was modified." (progn (add-text-properties (match-beginning 0) (match-end 0) (list 'mouse-face 'highlight + 'rear-nonsticky t 'keymap org-mouse-map )) t))) +(defmacro org-maybe-intangible (props) + "Add '(intangigble t) to PROPS if Emacs version is earlier than Emacs 22. +In emacs 21, invisible text is not avoided by the command loop, so the +intangible property is needed to make sure point skips this text. +In Emacs 22, this is not necessary. The intangible text property has +led to problems with flyspell. These problems are fixed in flyspell.el, +but we still avoid setting the property in Emacs 22 and later. +We use a macro so that the test can happen at compilation time." + (if (< emacs-major-version 22) + `(append '(intangible t) ,props) + props)) + (defun org-activate-bracket-links (limit) "Run through the buffer and add overlays to bracketed links." (if (re-search-forward org-bracket-link-regexp limit t) @@ -3377,9 +3430,10 @@ that will be added to PLIST. Returns the string that was modified." ;; FIXME: above we should remove the escapes. ;; but that requires another match, protecting match data, ;; a lot of overhead for font-lock. - (ip (list 'invisible 'org-link 'intangible t 'rear-nonsticky t - 'keymap org-mouse-map 'mouse-face 'highlight - 'help-echo help)) + (ip (org-maybe-intangible + (list 'invisible 'org-link 'rear-nonsticky t + 'keymap org-mouse-map 'mouse-face 'highlight + 'help-echo help))) (vp (list 'rear-nonsticky t 'keymap org-mouse-map 'mouse-face 'highlight 'help-echo help))) @@ -3399,11 +3453,20 @@ that will be added to PLIST. Returns the string that was modified." (defun org-activate-dates (limit) "Run through the buffer and add overlays to dates." - (if (re-search-forward org-tsr-regexp limit t) +; (if (re-search-forward org-tsr-regexp limit t) +; (if (re-search-forward +; (if org-display-custom-times org-ts-regexp-both org-tsr-regexp-both) +; limit t) + (if (re-search-forward org-tsr-regexp-both limit t) (progn (add-text-properties (match-beginning 0) (match-end 0) (list 'mouse-face 'highlight + 'rear-nonsticky t 'keymap org-mouse-map)) + (when org-display-custom-times + (if (match-end 3) + (org-display-custom-time (match-beginning 3) (match-end 3))) + (org-display-custom-time (match-beginning 1) (match-end 1))) t))) (defvar org-target-link-regexp nil @@ -3421,6 +3484,7 @@ that will be added to PLIST. Returns the string that was modified." (progn (add-text-properties (match-beginning 0) (match-end 0) (list 'mouse-face 'highlight + 'rear-nonsticky t 'keymap org-mouse-map 'help-echo "Radio target link" 'org-linked-text t)) @@ -3440,7 +3504,7 @@ that will be added to PLIST. Returns the string that was modified." 'org-cwidth t)) (when s (setq e (next-single-property-change s 'org-cwidth)) - (add-text-properties s e '(invisible org-cwidth intangible t)) + (add-text-properties s e (org-maybe-intangible '(invisible org-cwidth))) (goto-char e) t))) @@ -3486,6 +3550,7 @@ between words." (progn (add-text-properties (match-beginning 0) (match-end 0) (list 'mouse-face 'highlight + 'rear-nonsticky t 'keymap org-mouse-map)) t))) @@ -3494,6 +3559,7 @@ between words." (progn (add-text-properties (match-beginning 1) (match-end 1) (list 'mouse-face 'highlight + 'rear-nonsticky t 'keymap org-mouse-map)) t))) @@ -3600,8 +3666,10 @@ between words." (inhibit-modification-hooks t) deactivate-mark buffer-file-name buffer-file-truename) (remove-text-properties beg end - '(mouse-face nil keymap nil org-linked-text nil - invisible nil intangible nil)))) + '(mouse-face t keymap t org-linked-text t + rear-nonsticky t + invisible t intangible t)))) + ;;; Visibility cycling (defvar org-cycle-global-status nil) @@ -4026,6 +4094,7 @@ Return t when things worked, nil when we are not in an item." (progn (org-beginning-of-item) (org-at-item-p) + (if (org-invisible-p) (error "Invisible item")) t) (error nil))) (let* ((bul (match-string 0)) @@ -4117,13 +4186,13 @@ in the region." (equal (char-before) ?*) (forward-char 1))) -(defun org-get-legal-level (level change) +(defun org-get-legal-level (level &optional change) "Rectify a level change under the influence of `org-odd-levels-only' LEVEL is a current level, CHANGE is by how much the level should be modified. Even if CHANGE is nil, LEVEL may be returned modified because even level numbers will become the next higher odd number." (if org-odd-levels-only - (cond ((not change) (1+ (* 2 (/ level 2)))) + (cond ((or (not change) (= 0 change)) (1+ (* 2 (/ level 2)))) ((> change 0) (1+ (* 2 (/ (+ level (* 2 change)) 2)))) ((< change 0) (max 1 (1+ (* 2 (/ (+ level (* 2 change)) 2)))))) (max 1 (+ level change)))) @@ -4889,9 +4958,7 @@ this heading. " (beginning-of-line 1) (looking-at org-todo-line-regexp) (goto-char (or (match-end 2) (match-beginning 3))) - (insert "(" (format-time-string (cdr org-time-stamp-formats) - (org-current-time)) - ")")) + (org-insert-time-stamp (org-current-time) t t "(" ")")) ;; Save the buffer, if it is not the same buffer. (if (not (eq this-buffer buffer)) (save-buffer)))) ;; Here we are back in the original buffer. Everything seems to have @@ -5422,7 +5489,7 @@ prefix arg, switch to that state." (not (equal state org-done-string))) (when org-log-done (if (equal state org-done-string) - (org-add-planning-info 'closed (current-time) 'scheduled) + (org-add-planning-info 'closed (org-current-time) 'scheduled) (if (not this) (org-add-planning-info nil nil 'closed)))) ;; Fixup tag positioning @@ -5482,61 +5549,55 @@ be removed." (when (and org-insert-labeled-timestamps-at-point (member what '(scheduled deadline))) (insert - (if (eq what 'scheduled) org-scheduled-string org-deadline-string) - " " - (format-time-string (car org-time-stamp-formats) time)) + (if (eq what 'scheduled) org-scheduled-string org-deadline-string) " ") + (org-insert-time-stamp time) (setq what nil)) (save-excursion - (let (col list elt ts buffer-invisibility-spec) - (org-back-to-heading t) - (looking-at (concat outline-regexp "\\( *\\)[^\r\n]*")) - (goto-char (match-end 1)) - (setq col (current-column)) - (goto-char (1+ (match-end 0))) - (if (and (not (looking-at outline-regexp)) - (looking-at (concat "[^\r\n]*?" org-keyword-time-regexp - "[^\r\n]*")) - (not (equal (match-string 1) org-clock-string))) - (narrow-to-region (match-beginning 0) (match-end 0)) - (insert "\n") - (backward-char 1) - (narrow-to-region (point) (point)) - (indent-to-column col)) - ;; Check if we have to remove something. - (setq list (cons what remove)) - (while list - (setq elt (pop list)) + (save-restriction + (let (col list elt ts buffer-invisibility-spec) + (org-back-to-heading t) + (looking-at (concat outline-regexp "\\( *\\)[^\r\n]*")) + (goto-char (match-end 1)) + (setq col (current-column)) + (goto-char (1+ (match-end 0))) + (if (and (not (looking-at outline-regexp)) + (looking-at (concat "[^\r\n]*?" org-keyword-time-regexp + "[^\r\n]*")) + (not (equal (match-string 1) org-clock-string))) + (narrow-to-region (match-beginning 0) (match-end 0)) + (insert "\n") + (backward-char 1) + (narrow-to-region (point) (point)) + (indent-to-column col)) + ;; Check if we have to remove something. + (setq list (cons what remove)) + (while list + (setq elt (pop list)) + (goto-char (point-min)) + (when (or (and (eq elt 'scheduled) + (re-search-forward org-scheduled-time-regexp nil t)) + (and (eq elt 'deadline) + (re-search-forward org-deadline-time-regexp nil t)) + (and (eq elt 'closed) + (re-search-forward org-closed-time-regexp nil t))) + (replace-match "") + (if (looking-at " +") (replace-match "")))) + (goto-char (point-max)) + (when what + (insert + (if (not (equal (char-before) ?\ )) " " "") + (cond ((eq what 'scheduled) org-scheduled-string) + ((eq what 'deadline) org-deadline-string) + ((eq what 'closed) org-closed-string)) + " ") + (org-insert-time-stamp time nil (eq what 'closed)) + (end-of-line 1) + (org-add-log-maybe 'done)) (goto-char (point-min)) - (when (or (and (eq elt 'scheduled) - (re-search-forward org-scheduled-time-regexp nil t)) - (and (eq elt 'deadline) - (re-search-forward org-deadline-time-regexp nil t)) - (and (eq elt 'closed) - (re-search-forward org-closed-time-regexp nil t))) - (replace-match "") - (if (looking-at " +") (replace-match "")))) - (goto-char (point-max)) - (when what - (insert - (if (not (equal (char-before) ?\ )) " " "") - (cond ((eq what 'scheduled) org-scheduled-string) - ((eq what 'deadline) org-deadline-string) - ((eq what 'closed) org-closed-string)) - " ") - (insert - (setq ts - (format-time-string - (if (eq what 'closed) - (concat "[" (substring (cdr org-time-stamp-formats) 1 -1) "]") - (car org-time-stamp-formats)) - time))) - (end-of-line 1) - (org-add-log-maybe 'done)) - (goto-char (point-min)) - (widen) - (if (looking-at "[ \t]+\r?\n") - (replace-match "")) - ts))) + (widen) + (if (looking-at "[ \t]+\r?\n") + (replace-match "")) + ts)))) (defvar org-log-note-marker (make-marker)) (defvar org-log-note-purpose nil) @@ -5586,7 +5647,7 @@ be removed." (if (not (bolp)) (newline)) (indent-relative t) (setq ind (concat (buffer-substring (point-at-bol) (point)) " ")) - (insert "- " (pop lines)) + (insert " - " (pop lines)) (while lines (insert "\n" ind (pop lines)))))) (set-window-configuration org-log-note-window-configuration))) @@ -5665,8 +5726,16 @@ that the match should indeed be shown." (if (featurep 'xemacs) (set-extent-property ovl prop value) (overlay-put ovl prop value))) +(defun org-overlay-get (ovl prop) + (if (featurep 'xemacs) + (extent-property ovl prop) + (overlay-get ovl prop))) (defun org-overlays-at (pos) (if (featurep 'xemacs) (extents-at pos) (overlays-at pos))) +(defun org-overlays-in (&optional start end) + (if (featurep 'xemacs) + (extent-list nil start end) + (overlays-in start end))) (defun org-overlay-start (o) (if (featurep 'xemacs) (extent-start-position o) (overlay-start o))) (defun org-overlay-end (o) @@ -5775,10 +5844,7 @@ So if you press just return without typing anything, the time stamp will represent the current date/time. If there is already a timestamp at the cursor, it will be modified." (interactive "P") - (let ((fmt (if arg (cdr org-time-stamp-formats) - (car org-time-stamp-formats))) - (org-time-was-given nil) - time) + (let (org-time-was-given time) (cond ((and (org-at-timestamp-p) (eq last-command 'org-time-stamp) @@ -5786,21 +5852,19 @@ at the cursor, it will be modified." (insert "--") (setq time (let ((this-command this-command)) (org-read-date arg 'totime))) - (if org-time-was-given (setq fmt (cdr org-time-stamp-formats))) - (insert (format-time-string fmt time))) + (org-insert-time-stamp time (or org-time-was-given arg))) ((org-at-timestamp-p) (setq time (let ((this-command this-command)) (org-read-date arg 'totime))) - (and (org-at-timestamp-p) (replace-match - (setq org-last-changed-timestamp - (format-time-string fmt time)) - t t)) + (when (org-at-timestamp-p) ; just to get the match data + (replace-match "") + (setq org-last-changed-timestamp + (org-insert-time-stamp time (or org-time-was-given arg)))) (message "Timestamp updated")) (t (setq time (let ((this-command this-command)) - (org-read-date arg 'totime))) - (if org-time-was-given (setq fmt (cdr org-time-stamp-formats))) - (insert (format-time-string fmt time)))))) + (org-read-date arg 'totime))) + (org-insert-time-stamp time (or org-time-was-given arg)))))) (defun org-time-stamp-inactive (&optional arg) "Insert an inactive time stamp. @@ -5809,20 +5873,15 @@ brackets. It is inactive in the sense that it does not trigger agenda entries, does not link to the calendar and cannot be changed with the S-cursor keys. So these are more for recording a certain time/date." (interactive "P") - (let ((fmt (if arg (cdr org-time-stamp-formats) - (car org-time-stamp-formats))) - (org-time-was-given nil) - time) + (let (org-time-was-given time) (setq time (org-read-date arg 'totime)) - (if org-time-was-given (setq fmt (cdr org-time-stamp-formats))) - (setq fmt (concat "[" (substring fmt 1 -1) "]")) - (insert (format-time-string fmt time)))) + (org-insert-time-stamp time (or org-time-was-given arg) 'inactive))) (defvar org-date-ovl (org-make-overlay 1 1)) (org-overlay-put org-date-ovl 'face 'org-warning) (org-detatch-overlay org-date-ovl) -(defun org-read-date (&optional with-time to-time) +(defun org-read-date (&optional with-time to-time from-string) "Read a date and make things smooth for the user. The prompt will suggest to enter an ISO date, but you can also enter anything which will at least partially be understood by `parse-time-string'. @@ -5878,55 +5937,57 @@ used to insert the time stamp into the buffer to include the time." ans ans1 ans2 second minute hour day month year tl wday wday1) - (if org-popup-calendar-for-date-prompt - (save-excursion - (save-window-excursion - (calendar) - (calendar-forward-day (- (time-to-days default-time) - (calendar-absolute-from-gregorian - (calendar-current-date)))) - (org-eval-in-calendar nil) - (let* ((old-map (current-local-map)) - (map (copy-keymap calendar-mode-map)) - (minibuffer-local-map (copy-keymap minibuffer-local-map))) - (define-key map (kbd "RET") 'org-calendar-select) - (define-key map (if (featurep 'xemacs) [button1] [mouse-1]) - 'org-calendar-select-mouse) - (define-key map (if (featurep 'xemacs) [button2] [mouse-2]) - 'org-calendar-select-mouse) - (define-key minibuffer-local-map [(meta shift left)] - (lambda () (interactive) - (org-eval-in-calendar '(calendar-backward-month 1)))) - (define-key minibuffer-local-map [(meta shift right)] - (lambda () (interactive) - (org-eval-in-calendar '(calendar-forward-month 1)))) - (define-key minibuffer-local-map [(shift up)] - (lambda () (interactive) - (org-eval-in-calendar '(calendar-backward-week 1)))) - (define-key minibuffer-local-map [(shift down)] - (lambda () (interactive) - (org-eval-in-calendar '(calendar-forward-week 1)))) - (define-key minibuffer-local-map [(shift left)] - (lambda () (interactive) - (org-eval-in-calendar '(calendar-backward-day 1)))) - (define-key minibuffer-local-map [(shift right)] - (lambda () (interactive) - (org-eval-in-calendar '(calendar-forward-day 1)))) - (define-key minibuffer-local-map ">" - (lambda () (interactive) - (org-eval-in-calendar '(scroll-calendar-left 1)))) - (define-key minibuffer-local-map "<" - (lambda () (interactive) - (org-eval-in-calendar '(scroll-calendar-right 1)))) - (unwind-protect - (progn - (use-local-map map) - (setq ans (read-string prompt "" nil nil)) - (if (not (string-match "\\S-" ans)) (setq ans nil)) - (setq ans (or ans1 ans ans2))) - (use-local-map old-map))))) - ;; Naked prompt only - (setq ans (read-string prompt "" nil timestr))) + (cond + (from-string (setq ans from-string)) + (org-popup-calendar-for-date-prompt + (save-excursion + (save-window-excursion + (calendar) + (calendar-forward-day (- (time-to-days default-time) + (calendar-absolute-from-gregorian + (calendar-current-date)))) + (org-eval-in-calendar nil) + (let* ((old-map (current-local-map)) + (map (copy-keymap calendar-mode-map)) + (minibuffer-local-map (copy-keymap minibuffer-local-map))) + (define-key map (kbd "RET") 'org-calendar-select) + (define-key map (if (featurep 'xemacs) [button1] [mouse-1]) + 'org-calendar-select-mouse) + (define-key map (if (featurep 'xemacs) [button2] [mouse-2]) + 'org-calendar-select-mouse) + (define-key minibuffer-local-map [(meta shift left)] + (lambda () (interactive) + (org-eval-in-calendar '(calendar-backward-month 1)))) + (define-key minibuffer-local-map [(meta shift right)] + (lambda () (interactive) + (org-eval-in-calendar '(calendar-forward-month 1)))) + (define-key minibuffer-local-map [(shift up)] + (lambda () (interactive) + (org-eval-in-calendar '(calendar-backward-week 1)))) + (define-key minibuffer-local-map [(shift down)] + (lambda () (interactive) + (org-eval-in-calendar '(calendar-forward-week 1)))) + (define-key minibuffer-local-map [(shift left)] + (lambda () (interactive) + (org-eval-in-calendar '(calendar-backward-day 1)))) + (define-key minibuffer-local-map [(shift right)] + (lambda () (interactive) + (org-eval-in-calendar '(calendar-forward-day 1)))) + (define-key minibuffer-local-map ">" + (lambda () (interactive) + (org-eval-in-calendar '(scroll-calendar-left 1)))) + (define-key minibuffer-local-map "<" + (lambda () (interactive) + (org-eval-in-calendar '(scroll-calendar-right 1)))) + (unwind-protect + (progn + (use-local-map map) + (setq ans (read-string prompt "" nil nil)) + (if (not (string-match "\\S-" ans)) (setq ans nil)) + (setq ans (or ans1 ans ans2))) + (use-local-map old-map)))))) + (t ; Naked prompt only + (setq ans (read-string prompt "" nil timestr)))) (org-detatch-overlay org-date-ovl) (if (string-match @@ -5987,6 +6048,77 @@ This is used by `org-read-date' in a temporary keymap for the calendar buffer." (setq ans1 (format-time-string "%Y-%m-%d" time))) (if (active-minibuffer-window) (exit-minibuffer)))) +(defun org-insert-time-stamp (time &optional with-hm inactive pre post) + "Insert a date stamp for the date given by the internal TIME. +WITH-HM means, use the stamp format that includes the time of the day. +INACTIVE means use square brackets instead of angular ones, so that the +stamp will not contribute to the agenda. +PRE and POST are optional strings to be inserted before and after the +stamp. +The command returns the inserted time stamp." + (let ((fmt (funcall (if with-hm 'cdr 'car) org-time-stamp-formats)) + stamp) + (if inactive (setq fmt (concat "[" (substring fmt 1 -1) "]"))) + (insert (or pre "")) + (insert (setq stamp (format-time-string fmt time))) + (insert (or post "")) + stamp)) + +(defun org-toggle-time-stamp-overlays () + "Toggle the use of custom time stamp formats." + (interactive) + (setq org-display-custom-times (not org-display-custom-times)) + (unless org-display-custom-times + (let ((p (point-min)) (bmp (buffer-modified-p))) + (while (setq p (next-single-property-change p 'display)) + (if (and (get-text-property p 'display) + (eq (get-text-property p 'face) 'org-date)) + (remove-text-properties + p (setq p (next-single-property-change p 'display)) + '(display t)))) + (set-buffer-modified-p bmp))) + (if (featurep 'xemacs) + (remove-text-properties (point-min) (point-max) '(end-glyph t))) + (org-restart-font-lock) + (setq org-table-may-need-update t) + (if org-display-custom-times + (message "Time stamps are overlayed with custom format") + (message "Time stamp overlays removed"))) + +(defun org-display-custom-time (beg end) + "Overlay modified time stamp format over timestamp between BED and END." + (let* ((t1 (save-match-data + (org-parse-time-string (buffer-substring beg end) t))) + (w1 (- end beg)) + (with-hm (and (nth 1 t1) (nth 2 t1))) + (inactive (= (char-before (1- beg)) ?\[)) + (tf (funcall (if with-hm 'cdr 'car) org-time-stamp-custom-formats)) + (time (mapcar (lambda (x) (or x 0)) t1)) + (str (org-add-props + (format-time-string + (substring tf 1 -1) (apply 'encode-time time)) + nil 'mouse-face 'highlight)) + (w2 (length str))) + (if (not (= w2 w1)) + (add-text-properties (1+ beg) (+ 2 beg) + (list 'org-dwidth t 'org-dwidth-n (- w1 w2)))) + (if (featurep 'xemacs) + (progn + (put-text-property beg end 'invisible t) + (put-text-property beg end 'end-glyph (make-glyph str))) + (put-text-property beg end 'display str)))) + +(defun org-days-to-time (timestamp-string) + "Difference between TIMESTAMP-STRING and now in days." + (- (time-to-days (org-time-string-to-time timestamp-string)) + (time-to-days (current-time)))) + +(defun org-deadline-close (timestamp-string &optional ndays) + "Is the time in TIMESTAMP-STRING close to the current date?" + (and (< (org-days-to-time timestamp-string) + (or ndays org-deadline-warning-days)) + (not (org-entry-is-done-p)))) + (defun org-calendar-select-mouse (ev) "Return to `org-read-date' with the date currently selected. This is used by `org-read-date' in a temporary keymap for the calendar buffer." @@ -6013,12 +6145,8 @@ days. If the prefix is a raw \\[universal-argument] prefix, all deadlines are s (case-fold-search nil) (regexp (concat "\\<" org-deadline-string " *<\\([^>]+\\)>")) (callback - (lambda () - (and (let ((d1 (time-to-days (current-time))) - (d2 (time-to-days - (org-time-string-to-time (match-string 1))))) - (< (- d2 d1) org-warn-days)) - (not (org-entry-is-done-p)))))) + (lambda () (org-deadline-close (match-string 1) org-warn-days)))) + (message "%d deadlines past-due or due within %d days" (org-occur regexp nil callback) org-warn-days))) @@ -6185,21 +6313,23 @@ With prefix ARG, change that many days." The date will be changed by N times WHAT. WHAT can be `day', `month', `year', `minute', `second'. If WHAT is not given, the cursor position in the timestamp determines what will be changed." - (let ((fmt (car org-time-stamp-formats)) + (let ((pos (point)) + with-hm inactive org-ts-what - (pos (point)) ts time time0) (if (not (org-at-timestamp-p t)) (error "Not at a timestamp")) - (setq org-ts-what (or what org-ts-what)) - (setq fmt (if (<= (abs (- (cdr org-ts-lengths) + (if (and (not what) (not (eq org-ts-what 'day)) + org-display-custom-times + (get-text-property (point) 'display) + (not (get-text-property (1- (point)) 'display))) + (setq org-ts-what 'day)) + (setq org-ts-what (or what org-ts-what) + with-hm (<= (abs (- (cdr org-ts-lengths) (- (match-end 0) (match-beginning 0)))) 1) - (cdr org-time-stamp-formats) - (car org-time-stamp-formats))) - (if (= (char-after (match-beginning 0)) ?\[) - (setq fmt (concat "[" (substring fmt 1 -1) "]"))) - (setq ts (match-string 0)) + inactive (= (char-after (match-beginning 0)) ?\[) + ts (match-string 0)) (replace-match "") (setq time0 (org-parse-time-string ts)) (setq time @@ -6225,7 +6355,7 @@ in the timestamp determines what will be changed." (setcar (nthcdr 1 time0) (or (nth 1 time0) 0)) (setcar (nthcdr 2 time0) (or (nth 1 time0) 0)) (setq time (apply 'encode-time time0)))) - (insert (setq org-last-changed-timestamp (format-time-string fmt time))) + (org-insert-time-stamp time with-hm inactive) (org-clock-update-time-maybe) (goto-char pos) ;; Try to recenter the calendar window, if any @@ -6291,12 +6421,8 @@ If necessary, clock-out of the currently active clock." (beginning-of-line 1)) (insert "\n") (backward-char 1) (indent-relative) - (insert org-clock-string " " - (setq ts (concat "[" (format-time-string - (substring - (cdr org-time-stamp-formats) 1 -1) - (current-time)) - "]"))) + (insert org-clock-string " ") + (setq ts (org-insert-time-stamp (current-time) 'with-hm 'inactive)) (move-marker org-clock-marker (point)) (message "Clock started at %s" ts)))) @@ -6317,18 +6443,15 @@ If there is no running clock, throw an error, unless FAIL-QUIETLY is set." (setq ts (match-string 2)) (if fail-quietly (throw 'exit nil) (error "Clock start time is gone"))) (goto-char org-clock-marker) - (setq te (concat "[" (format-time-string - (substring - (cdr org-time-stamp-formats) 1 -1) - (current-time)) - "]")) + (insert "--") + (setq te (org-insert-time-stamp (current-time) 'with-hm 'inactive)) (setq s (- (time-to-seconds (apply 'encode-time (org-parse-time-string te))) (time-to-seconds (apply 'encode-time (org-parse-time-string ts)))) h (floor (/ s 3600)) s (- s (* 3600 h)) m (floor (/ s 60)) s (- s (* 60 s))) - (insert "--" te " => " (format "%2d:%02d" h m)) + (insert " => " (format "%2d:%02d" h m)) (move-marker org-clock-marker nil) (org-add-log-maybe 'clock-out) (message "Clock stopped at %s after HH:MM = %d:%02d" te h m))))) @@ -6437,7 +6560,10 @@ will be easy to remove." (make-string (- 10 l) ?\ )) '(face secondary-selection)) "")) - (org-overlay-put ov 'display tx) + (if (not (featurep 'xemacs)) + (org-overlay-put ov 'display tx) + (org-overlay-put ov 'invisible t) + (org-overlay-put ov 'end-glyph (make-glyph tx))) (push ov org-clock-overlays))) (defun org-remove-clock-overlays (&optional beg end noremove) @@ -6591,6 +6717,7 @@ the returned times will be formatted strings." (apply 'encode-time (org-parse-time-string te))))) (move-marker ins (point)) (setq ipos (point)) + ;; FIXME: does not yet use org-insert-time-stamp or custom format (insert-before-markers "Clock summary at [" (substring (format-time-string (cdr org-time-stamp-formats)) @@ -6884,11 +7011,11 @@ first press `1' to indicate that the agenda should be temporarily (until the next use of \\[org-agenda]) restricted to the current file." (interactive "P") (catch 'exit - (let ((restrict-ok (and buffer-file-name (org-mode-p))) - (buf (current-buffer)) - (bfn buffer-file-name) - (custom org-agenda-custom-commands) - c entry key type match lprops) + (let* ((buf (current-buffer)) + (bfn (buffer-file-name (buffer-base-buffer))) + (restrict-ok (and bfn (org-mode-p))) + (custom org-agenda-custom-commands) + c entry key type match lprops) ;; Turn off restriction (put 'org-agenda-files 'org-restrict nil) (setq org-agenda-restrict nil) @@ -7042,6 +7169,10 @@ before running the agenda command." (set-buffer "*Org Agenda*") (princ (buffer-string)))) +(defmacro org-no-read-only (&rest body) + "Inhibit read-only for BODY." + `(let ((inhibit-read-only t)) ,@body)) + (defun org-check-for-org-mode () "Make sure current buffer is in org-mode. Error if not." (or (org-mode-p) @@ -7766,6 +7897,7 @@ Needed to avoid empty dates which mess up holiday display." (error (add-to-diary-list original-date "Org-mode dummy" "" nil))))) +;;;###autoload (defun org-cycle-agenda-files () "Cycle through the files in `org-agenda-files'. If the current buffer visits an agenda file, find the next one in the list. @@ -8023,20 +8155,20 @@ the documentation of `org-diary'." (and (re-search-backward "[\r\n]\\*" nil t) (looking-at org-nl-done-regexp)))) -(defun org-at-date-range-p () +(defun org-at-date-range-p (&optional inactive-ok) "Is the cursor inside a date range?" (interactive) (save-excursion (catch 'exit (let ((pos (point))) - (skip-chars-backward "^<\r\n") - (skip-chars-backward "<") - (and (looking-at org-tr-regexp) + (skip-chars-backward "^[<\r\n") + (skip-chars-backward "<[") + (and (looking-at (if inactive-ok org-tr-regexp-both org-tr-regexp)) (>= (match-end 0) pos) (throw 'exit t)) - (skip-chars-backward "^<\r\n") - (skip-chars-backward "<") - (and (looking-at org-tr-regexp) + (skip-chars-backward "^<[\r\n") + (skip-chars-backward "<[") + (and (looking-at (if inactive-ok org-tr-regexp-both org-tr-regexp)) (>= (match-end 0) pos) (throw 'exit t))) nil))) @@ -8057,17 +8189,25 @@ the documentation of `org-diary'." "\\)\\>") org-not-done-regexp) "[^\n\r]*\\)")) - (sched-re (concat ".*\n?.*?" org-scheduled-time-regexp)) + (deadline-re (concat ".*\\(\n[^*].*\\)?" org-deadline-time-regexp)) + (sched-re (concat ".*\\(\n[^*].*\\)?" org-scheduled-time-regexp)) +; FIXME why was this wriong? (sched-re (concat ".*\n?.*?" org-scheduled-time-regexp)) marker priority category tags ee txt) (goto-char (point-min)) (while (re-search-forward regexp nil t) (catch :skip - (when (and org-agenda-todo-ignore-scheduled - (looking-at sched-re)) - ;; FIXME: the following test also happens below, but we need it here - (or org-agenda-todo-list-sublevels (org-end-of-subtree 'invisible)) - (throw :skip nil)) + (save-match-data + (beginning-of-line) + (when (or (and org-agenda-todo-ignore-scheduled + (looking-at sched-re)) + (and org-agenda-todo-ignore-deadlines + (looking-at deadline-re) + (org-deadline-close (match-string 2)))) + + ;; FIXME: the following test also happens below, but we need it here + (or org-agenda-todo-list-sublevels (org-end-of-subtree 'invisible)) + (throw :skip nil))) (org-agenda-skip) (goto-char (match-beginning 1)) (setq marker (org-agenda-new-marker (1+ (match-beginning 0))) @@ -8600,14 +8740,14 @@ HH:MM." (save-excursion (beginning-of-line 1) (setq re (get-text-property (point) 'org-not-done-regexp)) - (goto-char (+ (point) (get-text-property (point) 'prefix-length))) + (goto-char (+ (point) (or (get-text-property (point) 'prefix-length) 0))) (and (looking-at (concat "[ \t]*\\.*" re)) (add-text-properties (match-beginning 0) (match-end 0) '(face org-todo)))) (setq re (concat (get-text-property 0 'org-not-done-regexp x)) pl (get-text-property 0 'prefix-length x)) - (and re (equal (string-match (concat "\\(\\.*\\)" re) x pl) pl) - (add-text-properties (match-end 1) (match-end 0) + (and re (equal (string-match (concat "\\(\\.*\\)" re) x (or pl 0)) pl) + (add-text-properties (or (match-end 1) (match-end 0)) (match-end 0) '(face org-todo) x)) x))) @@ -9289,7 +9429,7 @@ MATCH can contain positive and negative selection of tags, like (let ((match0 match) minus tag mm tagsmatch todomatch tagsmatcher todomatcher kwd matcher orterms term orlist) - (if (string-match "//" match) + (if (string-match "/+" match) ;; match contains also a todo-matching request (setq tagsmatch (substring match 0 (match-beginning 0)) todomatch (substring match (match-end 0))) @@ -9415,7 +9555,7 @@ With prefix ARG, realign all tags in headings in the current buffer." (col (current-column)) (current (org-get-tags)) table current-tags inherited-tags ; computed below when needed - tags hd empty invis) + tags empty invis) (if arg (save-excursion (goto-char (point-min)) @@ -9725,7 +9865,7 @@ optional argument IN-EMACS is non-nil, Emacs will visit the file." (interactive "P") (setq org-window-config-before-follow-link (current-window-configuration)) (org-remove-occur-highlights nil nil t) - (if (org-at-timestamp-p) + (if (org-at-timestamp-p t) (org-follow-timestamp-link) (let (type path link line search (pos (point))) (catch 'match @@ -9887,9 +10027,9 @@ optional argument IN-EMACS is non-nil, Emacs will visit the file." ((string= type "shell") (let ((cmd path)) - (while (string-match "@{" cmd) + (while (string-match "@{" cmd) ; FIXME: not needed for [[]] links (setq cmd (replace-match "<" t t cmd))) - (while (string-match "@}" cmd) + (while (string-match "@}" cmd) ; FIXME: not needed for [[]] links (setq cmd (replace-match ">" t t cmd))) (if (or (not org-confirm-shell-link-function) (funcall org-confirm-shell-link-function @@ -10128,14 +10268,14 @@ onto the ring." (defun org-follow-timestamp-link () (cond - ((org-at-date-range-p) + ((org-at-date-range-p t) (let ((org-agenda-start-on-weekday) (t1 (match-string 1)) (t2 (match-string 2))) (setq t1 (time-to-days (org-time-string-to-time t1)) t2 (time-to-days (org-time-string-to-time t2))) (org-agenda-list nil t1 (1+ (- t2 t1))))) - ((org-at-timestamp-p) + ((org-at-timestamp-p t) (org-agenda-list nil (time-to-days (org-time-string-to-time (substring (match-string 1) 0 10))) 1)) @@ -10486,10 +10626,10 @@ If the file does not exist, an error is thrown." (error "No such file: %s" file)) (cond ((and (stringp cmd) (not (string-match "^\\s-*$" cmd))) - ;; Normalize use of quote, this can vary. + ;; Remove quotes around the file name - we'll use shell-quote-argument. (if (string-match "['\"]%s['\"]" cmd) - (setq cmd (replace-match "'%s'" t t cmd))) - (setq cmd (format cmd file)) + (setq cmd (replace-match "%s" t t cmd))) + (setq cmd (format cmd (shell-quote-argument file))) (save-window-excursion (shell-command (concat cmd " &")))) ((or (stringp cmd) @@ -10644,6 +10784,7 @@ For file links, arg negates `org-context-in-file-links'." link (org-make-link cpltxt)))) ((memq major-mode '(gnus-summary-mode gnus-article-mode)) + (require 'gnus-sum) (and (eq major-mode 'gnus-article-mode) (gnus-article-show-summary)) (gnus-summary-beginning-of-article) (let* ((group (car gnus-article-current)) @@ -11171,7 +11312,7 @@ See also the variable `org-reverse-note-order'." (outline-end-of-subtree)) (if (not (bolp)) (newline)) (beginning-of-line 1) - (org-paste-subtree (1+ level) txt)) + (org-paste-subtree (org-get-legal-level level 1) txt)) (t ;; Put it right there, with automatic level determined by ;; org-paste-subtree or from prefix arg @@ -11417,14 +11558,20 @@ This is being used to correctly align a single field after TAB or RET.") (make-string sp2 ?\ ) "%%%s%ds" (make-string sp1 ?\ ) "|")) (hfmt1 (concat (make-string sp2 ?-) "%s" (make-string sp1 ?-) "+")) - emptystrings links narrow fmax f1 len c e) + emptystrings links dates narrow fmax f1 len c e) (untabify beg end) - (remove-text-properties beg end '(org-cwidth t display t)) - ;; Check if we have links + (remove-text-properties beg end '(org-cwidth t org-dwidth t display t)) + ;; Check if we have links or dates (goto-char beg) (setq links (re-search-forward org-bracket-link-regexp end t)) + (goto-char beg) + (setq dates (and org-display-custom-times + (re-search-forward org-ts-regexp-both end t))) ;; Make sure the link properties are right (when links (goto-char beg) (while (org-activate-bracket-links end))) + ;; Make sure the date properties are right + (when dates (goto-char beg) (while (org-activate-dates end))) + ;; Check if we are narrowing any columns (goto-char beg) (setq narrow (and org-format-transports-properties-p @@ -11513,7 +11660,7 @@ This is being used to correctly align a single field after TAB or RET.") (string-match org-bracket-link-regexp (car c)) (< (org-string-width (car c)) len)) (setcar c (concat (car c) (make-string (- len (org-string-width (car c))) ?\ ))))))) - + ;; Compute the formats needed for output of the table (setq rfmt (concat indent "|") hfmt (concat indent "|")) (while (setq l (pop lengths)) @@ -11552,7 +11699,7 @@ This is being used to correctly align a single field after TAB or RET.") This ignores character with invisibility property `org-link', and also characters with property `org-cwidth', because these will become invisible upon the next fontification round." - (let (b) + (let (b l) (when (or (eq t buffer-invisibility-spec) (assq 'org-link buffer-invisibility-spec)) (while (setq b (text-property-any 0 (length s) @@ -11564,7 +11711,10 @@ upon the next fontification round." (setq s (concat (substring s 0 b) (substring s (or (next-single-property-change b 'org-cwidth s) (length s)))))) - (string-width s))) + (setq l (string-width s) b -1) + (while (setq b (text-property-any (1+ b) (length s) 'org-dwidth t s)) + (setq l (- l (get-text-property b 'org-dwidth-n s)))) + l)) (defun org-table-begin (&optional table-type) "Find the beginning of the table and return its position. @@ -16138,6 +16288,7 @@ The images can be removed again with \\[org-ctrl-c-ctrl-c]." (define-key org-mode-map "\C-c\C-x\M-w" 'org-copy-special) (define-key org-mode-map "\C-c\C-x\C-y" 'org-paste-special) +(define-key org-mode-map "\C-c\C-x\C-t" 'org-toggle-time-stamp-overlays) (define-key org-mode-map "\C-c\C-x\C-i" 'org-clock-in) (define-key org-mode-map "\C-c\C-x\C-o" 'org-clock-out) (define-key org-mode-map "\C-c\C-x\C-x" 'org-clock-cancel) @@ -16227,6 +16378,12 @@ because, in this case the deletion might narrow the column." (delete-char N)) (delete-char N))) +;; Make `delete-selection-mode' work with org-mode and orgtbl-mode +(put 'org-self-insert-command 'delete-selection t) +(put 'orgtbl-self-insert-command 'delete-selection t) +(put 'org-delete-char 'delete-selection 'supersede) +(put 'org-delete-backward-char 'delete-selection 'supersede) + ;; How to do this: Measure non-white length of current string ;; If equal to column width, we should realign. @@ -16662,6 +16819,9 @@ See the individual commands for more information." ["Schedule Item" org-schedule t] ["Deadline" org-deadline t] "--" + ["Custom time format" org-toggle-time-stamp-overlays + :style radio :selected org-display-custom-times] + "--" ["Goto Calendar" org-goto-calendar t] ["Date from Calendar" org-date-from-calendar t]) ("Logging work" @@ -17174,25 +17334,12 @@ Show the heading too, if it is currently invisible." (org-invisible-p))) (org-show-hierarchy-above 'bookmark-jump))) +;; Make session.el ignore our circular variable +(eval-after-load "session" + '(add-to-list 'session-globals-exclude 'org-mark-ring)) + ;;; Experimental code -;(add-hook 'org-load-hook -; (lambda () -; (defun outline-show-heading () -; "Show the current heading and move to its end." -; (outline-flag-region -; (- (point) -; (cond -; ((bobp) 0) -; ((equal (buffer-substring -; (max (point-min) (- (point) 3)) (point)) -; "\n\n\n") -; 2) -; (t 1))) -; (progn (outline-end-of-heading) (point)) -; nil)))) - - ;;; Finish up @@ -17202,4 +17349,3 @@ Show the heading too, if it is currently invisible." ;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd ;;; org.el ends here - diff --git a/org.pdf b/org.pdf index 9ae580ba6..061a4be8e 100644 Binary files a/org.pdf and b/org.pdf differ diff --git a/org.texi b/org.texi index 6139979cb..aafa9db50 100644 --- a/org.texi +++ b/org.texi @@ -3,8 +3,8 @@ @setfilename ../info/org @settitle Org Mode Manual -@set VERSION 4.52 -@set DATE October 2006 +@set VERSION 4.53 +@set DATE November 2006 @dircategory Emacs @direntry @@ -170,11 +170,12 @@ Timestamps * Time stamps:: Assigning a time to a tree entry * Creating timestamps:: Commands which insert timestamps +* Custom time format:: If you cannot work with the ISO format * Progress logging:: Documenting when what work was done. Creating timestamps -* The date/time prompt:: +* The date/time prompt:: How org-mode helps you entring date and time Progress Logging @@ -316,6 +317,15 @@ structured ASCII file, as HTML, or (todo and agenda items only) as an iCalendar file. It can also serve as a publishing tool for a set of linked webpages. +An important design aspect that distinguishes Org-mode from other +packages like Planner/Muse is that it encougages to store every piece of +information only once. In Planner, you have project pages, day pages +and possibly other files, duplicating some information such as tasks. +In Org-mode, you only have notes files. In your notes you mark entries +as tasks, label them with tags and timestamps. All necessary lists like +a schedule for the day, the agenda for a meeting, tasks lists selected +by tags etc are created dynamically when you need them. + Org-mode keeps simple things simple. When first fired up, it should feel like a straightforward, easy to use outliner. Complexity is not imposed, but a large amount of functionality is available when you need @@ -328,12 +338,13 @@ example: @r{@bullet{} as an ASCII table editor with spreadsheet-like capabilities} @r{@bullet{} as a TODO list editor} @r{@bullet{} as a full agenda and planner with deadlines and work scheduling} +@r{@bullet{} as an environment to implement David Allen's GTD system} @r{@bullet{} as a simple hypertext system, with HTML export} @r{@bullet{} as a publishing tool to create a set of interlinked webpages} @end example -The Org-mode table editor can be integrated into any major mode by -activating the minor Orgtbl-mode. +Org-mode's automatic, context sensitive table editor can be integrated +into any major mode by activating the minor Orgtbl-mode. @cindex FAQ There is a website for Org-mode which provides links to the newest @@ -642,7 +653,9 @@ the middle of a line, the line is split and the rest of the line becomes the new headline. If the command is used at the beginning of a headline, the new headline is created before the current line. If at the beginning of any other line, the content of that line is made the -new heading. +new heading. If the command is used at the end of a folded subtree +(i.e. behind the ellipses at the end of a headline), then a headline +like the current one will be inserted after the end of the subtree. @kindex M-S-@key{RET} @item M-S-@key{RET} Insert new TODO entry with same level as current heading. @@ -2441,6 +2454,7 @@ planning. @menu * Time stamps:: Assigning a time to a tree entry * Creating timestamps:: Commands which insert timestamps +* Custom time format:: If you cannot work with the ISO format * Progress logging:: Documenting when what work was done. @end menu @@ -2454,10 +2468,12 @@ planning. @cindex scheduling A time stamp is a specification of a date (possibly with time) in a -special format, either @samp{<2003-09-16 Tue>} or @samp{<2003-09-16 -Tue 09:39>}. A time stamp can appear anywhere in the headline or body -of an org-tree entry. Its presence allows entries to be shown on specific -dates in the agenda (@pxref{Weekly/Daily agenda}). We distinguish: +special format, either @samp{<2003-09-16 Tue>} or @samp{<2003-09-16 Tue +09:39>}@footnote{This is the standard ISO date/time format. If you +cannot get used to these, see @ref{Custom time format}}. A time stamp +can appear anywhere in the headline or body of an org-tree entry. Its +presence allows entries to be shown on specific dates in the agenda +(@pxref{Weekly/Daily agenda}). We distinguish: @table @var @item Plain time stamp @@ -2468,6 +2484,21 @@ an event in a diary, when you want to take note of when something happened. In the timeline and agenda displays, the headline of an entry associated with a plain time stamp will be shown exactly on that date. +@example +* Meet Peter at the movies <2006-11-01 Wed 19:15> +@end example + +@item Inactive time stamp +@cindex timestamp, inactive +@cindex inactive timestamp +Just like a plain time stamp, but with square brackets instead of +angular ones. These time stamps are inactive in the sense that thay do +@emph{not} trigger an entry to show up in the agenda. + +@example +* Gillian comes late for the fifth time [2006-11-01 Wed] +@end example + @item Time stamp range @cindex timerange Two time stamps connected by @samp{--} denote a time range. The @@ -2524,7 +2555,7 @@ automatically into the file. The time stamps are enclosed in square brackets instead of angular brackets. @xref{Clocking work time}. @end table -@node Creating timestamps, Progress logging, Time stamps, Timestamps +@node Creating timestamps, Custom time format, Time stamps, Timestamps @section Creating timestamps @cindex creating timestamps @cindex timestamps, creating @@ -2563,8 +2594,8 @@ instead. @kindex C-c C-o @item C-c C-o -Access the agenda for the date given by the time stamp at point -(@pxref{Weekly/Daily agenda}). +Access the agenda for the date given by the time stamp or -range at +point (@pxref{Weekly/Daily agenda}). @kindex C-c C-d @item C-c C-d @@ -2598,11 +2629,11 @@ CUA-mode (@pxref{Conflicts}). @kindex S-@key{down} @item S-@key{up} @itemx S-@key{down} -Change the item under the cursor in a timestamp. The cursor can be on -a year, month, day, hour or minute. Note that if the cursor is not at -a time stamp, these same keys modify the priority of an item. -(@pxref{Priorities}). The key bindings also conflict with CUA-mode -(@pxref{Conflicts}). +Change the item under the cursor in a timestamp. The cursor can be on a +year, month, day, hour or minute. Note that if the cursor is in a +headline and not at a time stamp, these same keys modify the priority of +an item. (@pxref{Priorities}). The key bindings also conflict with +CUA-mode (@pxref{Conflicts}). @kindex C-c C-y @@ -2615,7 +2646,7 @@ into the following column). @menu -* The date/time prompt:: +* The date/time prompt:: How org-mode helps you entring date and time @end menu @node The date/time prompt, , Creating timestamps, Creating timestamps @@ -2680,10 +2711,53 @@ One month forward. One month back. @kindex @key{RET} @item @key{RET} -Choose date in calendar (only if nothing typed into minibuffer). +Choose date in calendar (only if nothing was typed into minibuffer). @end table -@node Progress logging, , Creating timestamps, Timestamps +@node Custom time format, Progress logging, Creating timestamps, Timestamps +@section Custom time format +@cindex custom date/time format +@cindex time format, custom +@cindex date format, custom + +Org-mode uses the standard ISO notation for dates and times as it is +defined in ISO 8601. If you cannot get used to this and require another +representation of date and time to keep you happy, you can get it by +customizing the variables @code{org-display-custom-times} and +@code{org-time-stamp-custom-formats}. + +@table @kbd +@kindex C-c C-x C-t +@item C-c C-x C-t +Toggle the display of custom formats for dates and times. +@end table + +@noindent +Org-mode needs the default format for scanning, so the custom date/time +format does not @emph{replace} the default format - instead it is put +@emph{over} the default format using text properties. This has the +following consequences: +@itemize @bullet +@item +You cannot place the cursor onto a time stamp anymore, only before or +after. +@item +The @kbd{S-@key{up}/@key{down}} keys can no longer be used to adjust +each component of a time stamp. If the cursor is at the beginning of +the stamp, @kbd{S-@key{up}/@key{down}} will change the stamp by one day, +just like @kbd{S-@key{left}/@key{right}}. At the end of the stamp, the +time will be changed by one minute. +@item +When you delete a time stamp character-by-character, it will only +disappear from the buffer after @emph{all} (invisible) characters +belonging to the ISO timestamp have been removed. +@item +If the custom time stamp format is longer than the default and you are +using dates in tables, table alignment will be messed up. If the custom +format is shorter, things do work as expected. +@end itemize + +@node Progress logging, , Custom time format, Timestamps @section Progress Logging @cindex progress logging @cindex logging, of progress @@ -2739,7 +2813,8 @@ keyword together with a timestamp. Stop the clock (clock-out). The inserts another timestamp at the same location where the clock was last started. It also directly computes the resulting time in inserts it after the time range as @samp{=> -HH:MM}. +HH:MM}. See the variable @code{org-log-done} for the possibility to +record an additional note together with a the clock-out time stamp. @kindex C-c C-y @item C-c C-y Recompute the time interval after changing one of the time stamps. This @@ -2759,7 +2834,8 @@ Display time summaries for each subtree in the current buffer. This puts overlays at the end of each headline, showing the total time recorded under that heading, including the time of any subheadings. You can use visibility cycling to study the tree, but the overlays disappear -automatically when the buffer is changed. +when you change the buffer (see variable +@code{org-remove-highlights-with-change}) or press @kbd{C-c C-c}. @kindex C-c C-x C-r @item C-c C-x C-r Insert a dynamic block (@pxref{Dynamic blocks}) containing a clock @@ -2807,9 +2883,6 @@ The @kbd{l} key may be used in the timeline (@pxref{Timeline}) and in the agenda (@pxref{Weekly/Daily agenda}) to show which tasks have been worked on or closed during a day. -See the variable @code{org-log-done} for the possibility to record an -additional note together with a the clock-out time stamp. - @node Tags, Agenda views, Timestamps, Top @chapter Tags @cindex tags @@ -3012,20 +3085,20 @@ tagged also @samp{NIGHT}. @cindex TODO keyword matching, with tags search If you are using multi-state TODO keywords (@pxref{TODO extensions}), it can be useful to also match on the TODO keyword. This can be done by -adding a condition after a double slash to a tags match. The syntax is -similar to the tag matches, but should be applied with consideration: -For example, a positive selection on several TODO keywords can not +adding a condition after a slash to a tags match. The syntax is similar +to the tag matches, but should be applied with consideration: For +example, a positive selection on several TODO keywords can not meaningfully be combined with boolean AND. However, @emph{negative selection} combined with AND can be meaningful. Examples: @table @samp -@item WORK//WAITING +@item WORK/WAITING Select @samp{:WORK:}-tagged TODO lines with the specific TODO keyword @samp{WAITING}. -@item WORK//-WAITING-NEXT +@item WORK/-WAITING-NEXT Select @samp{:WORK:}-tagged TODO lines that are neither @samp{WAITING} nor @samp{NEXT} -@item WORK//+WAITING|+NEXT +@item WORK/+WAITING|+NEXT Select @samp{:WORK:}-tagged TODO lines that are either @samp{WAITING} or @samp{NEXT}. @end table @@ -4944,6 +5017,12 @@ showstars @r{show all stars starting a headline} odd @r{allow only odd outline levels (1,3,...)} oddeven @r{allow all outline levels} @end example +To turn on custom format overlayes over time stamps (variables +@code{org-put-time-stamp-overlays} and +@code{org-time-stamp-overlay-formats}), use +@example +customtime @r{overlay custom time format} +@end example @item #+SEQ_TODO: #+TYP_TODO: These lines set the TODO keywords and their interpretation in the current file. The corresponding variables are @code{org-todo-keywords} diff --git a/orgcard.pdf b/orgcard.pdf index f9b72fbb2..87dc92f1a 100644 Binary files a/orgcard.pdf and b/orgcard.pdf differ diff --git a/orgcard.tex b/orgcard.tex index 013ec8dc5..7ef75aced 100644 --- a/orgcard.tex +++ b/orgcard.tex @@ -1,5 +1,5 @@ % Reference Card for Org Mode -\def\orgversionnumber{4.52} +\def\orgversionnumber{4.53} \def\year{2006} % %**start of header @@ -541,6 +541,7 @@ after ``{\tt :}'', and dictionary words elsewhere. %\key{... forward/backward one day}{S-LEFT/RIGHT} %\key{... forward/backward one week}{S-UP/DOWN} %\key{... forward/backward one month}{M-S-LEFT/RIGT} +\key{Toggle custom format display for dates/times}{C-c C-x C-t} \section{Clocking Time}