diff --git a/Makefile b/Makefile index b9ab5fc42..c5d595d67 100644 --- a/Makefile +++ b/Makefile @@ -74,6 +74,12 @@ install: install-lisp doc: org.html org.pdf orgcard.pdf +p: + make pdf && open org.pdf + +c: + make card && gv orgcard.ps + install-lisp: $(LISPFILES) $(ELCFILES) if [ ! -d $(lispdir) ]; then $(MKDIR) $(lispdir); else true; fi ; $(CP) $(LISPFILES) $(lispdir) diff --git a/org b/org index 029535351..11f1a2151 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.67). + This manual is for Org-mode (version 4.68). Copyright (C) 2004, 2005, 2006, 2007 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.67). +This manual is for Org-mode (version 4.68). Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation @@ -131,7 +131,7 @@ TODO items * TODO basics:: Marking and displaying TODO entries * TODO extensions:: Workflow and assignments * Priorities:: Some things are more important than others -* Breaking down tasks:: Splitting a task into managable pieces +* Breaking down tasks:: Splitting a task into manageable pieces * Checkboxes:: Tick-off lists Extended use of TODO keywords @@ -212,7 +212,7 @@ Exporting HTML export -* Export commands:: How to invode HTML export +* Export commands:: How to invoke HTML export * Quoting HTML tags:: Using direct HTML in Org-mode * Links:: How hyperlinks get transferred to HTML * Images:: To inline or not to inline? @@ -338,7 +338,7 @@ example as: Org-mode's automatic, context sensitive table editor with spreadsheet capabilities can be integrated into any major mode by activating the minor Orgtbl-mode. Using a translation step, it can be used to maintain -tables in arbitray file types, for example in LaTeX. +tables in arbitrary file types, for example in LaTeX. There is a website for Org-mode which provides links to the newest version of Org-mode, as well as additional information, frequently asked @@ -1169,7 +1169,7 @@ to no more than this value. Fields that are wider become clipped and end in the string `=>'. Note that the full text is still in the buffer, it is only invisible. To -see the full text, hold the mouse over the field - a tooltip window +see the full text, hold the mouse over the field - a tool-tip window will show the full content. To edit such a field, use the command `C-c `' (that is `C-c' followed by the backquote). This will open a new window with the full field. Edit it and finish with `C-c C-c'. @@ -1205,7 +1205,7 @@ in mail mode, use Furthermore, with some special setup, it is possible to maintain tables in arbitrary syntax with Orgtbl-mode. For example, it is possible to construct LaTeX tables with the underlying ease and power of -Orgtbl-mode, including spreadsheet capabulities. For details, see +Orgtbl-mode, including spreadsheet capabilities. For details, see *Note Tables in arbitrary syntax::.  @@ -1216,7 +1216,11 @@ File: org, Node: The spreadsheet, Prev: orgtbl-mode, Up: Tables The table editor makes use of the Emacs `calc' package to implement spreadsheet-like capabilities. It can also evaluate Emacs Lisp forms to -derive fields from other fields. +derive fields from other fields. While fully featured, Org-mode's +implementation is not identical to other spreadsheets. For example, +Org-mode knows the concept of a _column formula_ that will be applied +to all non-header fields in a column without having to copy the formula +to each relevant field. * Menu: @@ -1238,16 +1242,21 @@ File: org, Node: References, Next: Formula syntax for Calc, Prev: The spreads To compute fields in the table from other fields, formulas must reference other fields or ranges. In Org-mode, fields can be referenced by name, by absolute coordinates, and by relative coordinates. To find -out what the coordinates of a field are, press `C-c ?' in that field. +out what the coordinates of a field are, press `C-c ?' in that field, +or press `C-c }' to toggle the display of a grid. Field references ................ -Formulas can reference the value of another field with the operator +Formulas can reference the value of another field in two ways. Like in +any other spreadsheet, you may reference fields with a letter/number +combination like `B3', meaning the 2nd field in the 3rd row. + +Org-mode also uses another, more general operator that looks like this: @row$column - Column references can be absolute like `1', `2',...`N', or relative -to the current column like `+1' or `-2'. +Column references can be absolute like `1', `2',...`N', or relative to +the current column like `+1' or `-2'. The row specification only counts data lines and ignores horizontal separator lines (hlines). You can use absolute row numbers `1'...`N', @@ -1264,17 +1273,19 @@ the value directly at the hline is used. the column or the row part of the reference, the current row/column is implied. - Org-mode's references with _positive_ numbers correspond to fixed -references in other spreadsheet programs. For example, `@3$28' -corresponds to `$AB$3'. Org-mode's references with _negative_ numbers -behave similar to non-fixed references in other spreadsheet programs, -because when the same formula is used in several fields, different -fields are referenced each time. + Org-mode's references with _unsigned_ numbers are fixed references +in the sense that if you use the same reference in the formula for two +different fields, the same field will be referenced each time. +Org-mode's references with _signed_ numbers are floating references +because the same reference operator can reference different fields +depending on the field being calculated by the formula. Here are a few examples: @2$3 2nd row, 3rd column + C2 same as previous $5 column 5 in the current row + E& same as previous @2 current column, row 2 @-1$-3 the field one row up, three columns to the left @-I$2 field just under hline above current row, column 2 @@ -1292,6 +1303,7 @@ order to be interpreted correctly). Examples: $1..$3 First three fields in the current row. $P..$Q Range, using column names (see under Advanced) @2$1..@4$3 6 fields between these two fields. + A2..C4 Same as above. @-1$-2..@-1 3 numbers from the column to the left, 2 up to current row Range references return a vector of values that can be fed into Calc @@ -1307,9 +1319,17 @@ Named references Constants are defined globally through the variable `org-table-formula-constants'. If you have the `constants.el' package, it will also be used to resolve constants, including natural constants -like `$h' for Planck's constant, and units like `$km' for kilometers. -Column names and parameters can be specified in special table lines. -These are described below, see *Note Advanced features::. +like `$h' for Planck's constant, and units like `$km' for +kilometers(1). Column names and parameters can be specified in special +table lines. These are described below, see *Note Advanced features::. + + ---------- Footnotes ---------- + + (1) `Constant.el' can supply the values of constants in two +different unit systems, `SI' and `cgs'. Which one is used depends on +the value of the variable `constants-unit-system'. You can use the +`#+STARTUP' options `constSI' and `constcgs' to set this value for the +current buffer.  File: org, Node: Formula syntax for Calc, Next: Formula syntax for Lisp, Prev: References, Up: The spreadsheet @@ -1348,7 +1368,7 @@ the final result. A few examples: $1+$2 Sum of first and second field $1+$2;%.2f Same, format result to two decimals exp($2)+exp($1) Math functions can be used - $;%.1f Reformat current cell to 1 decimal + $0;%.1f Reformat current cell to 1 decimal ($3-32)*5/9 Degrees F -> C conversion $c/$1/$cm Hz -> cm conversion, using `constants.el' tan($1);Dp3s1 Compute in degrees, precision 3, display SCI 1 @@ -1357,6 +1377,10 @@ the final result. A few examples: vmean($2..$7);EN Same, but treat empty fields as 0 taylor($3,x=7,2) taylor series of $3, at x=7, second degree + Calc also contains a complete set of logical operations. For example + + if($1<20,teen,string("")) "teen" if age $1 less than 20, else empty +  File: org, Node: Formula syntax for Lisp, Next: Field formulas, Prev: Formula syntax for Calc, Up: The spreadsheet @@ -1364,16 +1388,17 @@ File: org, Node: Formula syntax for Lisp, Next: Field formulas, Prev: Formula ---------------------------------- It is also possible to write a formula in Emacs Lisp; this can be useful -for string manipulation and control structures. If a formula starts -with a single quote followed by an opening parenthesis, then it is -evaluated as a lisp form. The evaluation should return either a string -or a number. Just as with `calc' formulas, you can specify modes and a -printf format after a semicolon. A reference will be replaced with a -string (in double quotes) containing the field. If you provide the `N' -mode switch, all referenced elements will be numbers. Ranges are -inserted as space-separated fields, so you can embed them in list or -vector syntax. A few examples, note how the `N' mode is used when we -do computations in lisp. +for string manipulation and control structures, if the Calc's +functionality is not enough. If a formula starts with a single quote +followed by an opening parenthesis, then it is evaluated as a lisp form. +The evaluation should return either a string or a number. Just as with +`calc' formulas, you can specify modes and a printf format after a +semicolon. A reference will be replaced with a string (in double +quotes) containing the field. If you provide the `N' mode switch, all +referenced elements will be numbers. Ranges are inserted as +space-separated fields, so you can embed them in list or vector syntax. +A few examples, note how the `N' mode is used when we do computations +in lisp. Swap the first two characters of the content of column 1 '(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2)) @@ -1397,11 +1422,11 @@ current field replaced with the result. Formulas are stored in a special line starting with `#+TBLFM:' directly below the table. If you typed the equation in the 4th field of the 3rd data line in the table, the formula will look like -`@3$2=$1+$2'. When inserting/deleting/swapping column and rows with +`@3$4=$1+$2'. When inserting/deleting/swapping column and rows with the appropriate commands, absolute references (but not relative ones) in stored formulas are modified in order to still reference the same field. Of cause this is not true if you edit the table structure with -normal editing commands - then you must go and fix equations yourself. +normal editing commands - then you must fix the equations yourself. Instead of typing an equation into the field, you may also use the following command @@ -1420,7 +1445,9 @@ File: org, Node: Column formulas, Next: Editing and debugging formulas, Prev: Often in a table, the same formula should be used for all fields in a particular column. Instead of having to copy the formula to all fields in that column, org-mode allows to assign a single formula to an entire -column. +column. If the table contains horizontal separator hlines, everything +before the first such line is considered part of the table _header_ and +will not be modified by column formulas. To assign a formula to a column, type it directly into any field in the column, preceded by an equal sign, like `=$1+$2'. When you press @@ -1451,7 +1478,11 @@ File: org, Node: Editing and debugging formulas, Next: Updating the table, Pr You can edit individual formulas in the minibuffer or directly in the field. Org-mode can also prepare a special buffer with all active -formulas of a table. +formulas of a table. When offering a formula for editing, Org-mode +converts references to the standard format (like `B3' or `D&') if +possible. If you prefer to only work with the internal format (like +`@3$2' or `$4'), configure the variable +`org-table-use-standard-references'. `C-c =' `C-u C-c =' @@ -1469,18 +1500,34 @@ formulas of a table. While editing a formula in a table field, highlight the field(s) referenced by the reference at the cursor position in the formula. +`C-c }' + Toggle the display of row and column numbers for a table, using + overlays. These are updated each time the table is aligned, you + can force it with `C-c C-c'. + +`C-c {' + Toggle the formula debugger on and off. See below. + `C-c '' Edit all formulas for the current table in a special buffer, where - the formulas will be displayed one per line. While inside the - special buffer, Org-mode will automatically highlight any field or - range reference at the cursor position. You may edit, remove and - add formulas, and use the following commands: + the formulas will be displayed one per line. If the current field + has an active formula, the cursor in the formula editor will mark + it. While inside the special buffer, Org-mode will automatically + highlight any field or range reference at the cursor position. + You may edit, remove and add formulas, and use the following + commands: `C-c C-c' - Exit the buffer and store the modified formulas. With `C-u' - prefix, also apply the new formulas to the entire table. + `C-x C-s' + Exit the formula editor and store the modified formulas. + With `C-u' prefix, also apply the new formulas to the entire + table. `C-c C-q' - Exit the buffer without installing changes. + Exit the formula editor without installing changes. + + `C-c C-r' + Toggle all references in the formula editor between standard + (like `B3') and internal (like `@3$2'). `' Pretty-print or indent lisp formula at point. When in a line @@ -1492,21 +1539,20 @@ formulas of a table. `M-' Complete Lisp symbols, just like in Emacs-lisp-mode. - `S-/' - Move the reference line in the Org-mode buffer up and down. - This is important for highlighting the references of column - formulas for different rows. + `S-///' + Shift the reference at point. For example, if the reference + is `B3' and you press `S-', it will become `C3'. This + also works for relative references, and for hline references. + + `M-S-/' + Move the test line for column formulas in the Org-mode buffer + up and down. `M-/' - Scroll the window displaying the table. - -`C-c }' - Toggle the display of row and column numbers for a table, using - overlays. These are uptated each time the table is aligned, you - can force it with `C-c C-c'. + Scroll the window displaying the table. -`C-c {' - Toggle the formula debugger on and off. See below. + `C-c }' + Turn the coordinate grid in the table on and off. Making a table field blank does not remove the formula associated with the field, because that is stored in a different line (the `TBLFM' @@ -1525,8 +1571,8 @@ When the evaluation of a formula leads to an error, the field content becomes the string `#ERROR'. If you would like see what is going on during variable substitution and calculation in order to find a bug, turn on formula debugging in the `Tbl' menu and repeat the calculation, -for example by pressing `C-c = ' in a field. Detailed information -will be displayed. +for example by pressing `C-u C-u C-c = ' in a field. Detailed +information will be displayed.  File: org, Node: Updating the table, Next: Advanced features, Prev: Editing and debugging formulas, Up: The spreadsheet @@ -2153,7 +2199,7 @@ template has been expanded: If you change you mind about which template to use, call `org-remember' in the remember buffer. You may then select a new template that will -be filled with the previoous context information. +be filled with the previous context information. ---------- Footnotes ---------- @@ -2220,7 +2266,7 @@ overview over all things you have to do. * TODO basics:: Marking and displaying TODO entries * TODO extensions:: Workflow and assignments * Priorities:: Some things are more important than others -* Breaking down tasks:: Splitting a task into managable pieces +* Breaking down tasks:: Splitting a task into manageable pieces * Checkboxes:: Tick-off lists  @@ -2423,7 +2469,7 @@ File: org, Node: Breaking down tasks, Next: Checkboxes, Prev: Priorities, Up 5.4 Breaking tasks down into subtasks ===================================== -It is often advisable to break down large tasks into smaller, managable +It is often advisable to break down large tasks into smaller, manageable subtasks. You can do this by creating an outline tree below a TODO item, with detailed subtasks on the tree(1). Another possibility is the use of checkboxes to identify (a hierarchy of) a large number of @@ -2626,8 +2672,8 @@ format. minutes, see the option `org-time-stamp-rounding-minutes'. `C-c !' - Like `C-c .', but insert an inactive time stamp not triggering the - agenda. + Like `C-c .', but insert an inactive time stamp that will not cause + an agenda entry. `C-c <' Insert a time stamp corresponding to the cursor date in the @@ -4353,7 +4399,7 @@ but with additional support for tables. * Menu: -* Export commands:: How to invode HTML export +* Export commands:: How to invoke HTML export * Quoting HTML tags:: Using direct HTML in Org-mode * Links:: How hyperlinks get transferred to HTML * Images:: To inline or not to inline? @@ -5100,6 +5146,10 @@ file is visited again in a new Emacs session. `org-put-time-stamp-overlays' and `org-time-stamp-overlay-formats'), use customtime overlay custom time format + The following options influence the table spreadsheet (variable + `constants-unit-system'). + constcgs `constants.el' should use the c-g-s unit system + constSI `constants.el' should use the SI unit system `#+SEQ_TODO: #+TYP_TODO:' These lines set the TODO keywords and their interpretation in the @@ -6093,8 +6143,10 @@ Index * completion, of TeX symbols: Completion. (line 6) * completion, of TODO keywords <1>: Completion. (line 6) * completion, of TODO keywords: Workflow states. (line 12) -* constants, in calculations: References. (line 74) +* constants, in calculations: References. (line 82) * constants.el: Cooperation. (line 14) +* constcgs, STARTUP keyword: In-buffer settings. (line 52) +* constSI, STARTUP keyword: In-buffer settings. (line 52) * content, STARTUP keyword: In-buffer settings. (line 22) * contents, global visibility state: Visibility cycling. (line 22) * copying, of subtrees: Structure editing. (line 6) @@ -6118,7 +6170,7 @@ Index * deadlines: Time stamps. (line 6) * deadlines, repeating: Repeating items. (line 6) * debugging, of table formulas: Editing and debugging formulas. - (line 78) + (line 97) * demotion, of subtrees: Structure editing. (line 6) * diary entries, creating from agenda: Agenda commands. (line 198) * diary integration: Weekly/Daily agenda. (line 24) @@ -6148,7 +6200,7 @@ Index * FAQ: Summary. (line 53) * feedback: Feedback. (line 6) * field formula: Field formulas. (line 6) -* field references: References. (line 14) +* field references: References. (line 15) * file links: External links. (line 6) * file links, searching: Search options. (line 6) * file name completion: Handling links. (line 43) @@ -6164,7 +6216,7 @@ Index (line 15) * format, of links: Link format. (line 6) * formula debugging: Editing and debugging formulas. - (line 78) + (line 97) * formula editing: Editing and debugging formulas. (line 6) * formula syntax, Calc: Formula syntax for Calc. @@ -6259,8 +6311,8 @@ Index (line 15) * motion commands in agenda: Agenda commands. (line 19) * motion, between headlines: Motion. (line 6) -* name, of column or field: References. (line 74) -* named references: References. (line 74) +* name, of column or field: References. (line 82) +* named references: References. (line 82) * names as TODO keywords: TODO types. (line 6) * narrow columns in tables: Narrow columns. (line 6) * noalign, STARTUP keyword: In-buffer settings. (line 29) @@ -6306,13 +6358,13 @@ Index * quoted HTML tags: Export options. (line 25) * radio tables: Radio tables. (line 6) * radio targets: Radio targets. (line 6) -* range references: References. (line 53) +* range references: References. (line 60) * ranges, time: Time stamps. (line 6) * recomputing table fields: Updating the table. (line 6) * references: References. (line 6) -* references, named: References. (line 74) -* references, to fields: References. (line 14) -* references, to ranges: References. (line 53) +* references, named: References. (line 82) +* references, to fields: References. (line 15) +* references, to ranges: References. (line 60) * region, active <1>: Export commands. (line 6) * region, active <2>: ASCII export. (line 9) * region, active <3>: Built-in table editor. @@ -6477,7 +6529,7 @@ Key Index * <2>: Agenda commands. (line 35) * <3>: Setting tags. (line 68) * <4>: Editing and debugging formulas. - (line 37) + (line 57) * <5>: Built-in table editor. (line 57) * <6>: Plain lists. (line 37) @@ -6502,7 +6554,7 @@ Key Index * C-c %: Handling links. (line 81) * C-c &: Handling links. (line 85) * C-c ': Editing and debugging formulas. - (line 24) + (line 36) * C-c *: Updating the table. (line 13) * C-c +: Built-in table editor. (line 141) @@ -6517,11 +6569,11 @@ Key Index * C-c : Built-in table editor. (line 163) * C-c = <1>: Editing and debugging formulas. - (line 10) -* C-c =: Column formulas. (line 24) + (line 14) +* C-c =: Column formulas. (line 26) * C-c >: Creating timestamps. (line 29) * C-c ?: Editing and debugging formulas. - (line 20) + (line 24) * C-c [: Agenda files. (line 12) * C-c \: Tag searches. (line 9) * C-c ]: Agenda files. (line 15) @@ -6553,7 +6605,7 @@ Key Index * C-c C-c <4>: Setting tags. (line 10) * C-c C-c <5>: Checkboxes. (line 37) * C-c C-c <6>: Editing and debugging formulas. - (line 32) + (line 46) * C-c C-c <7>: Built-in table editor. (line 54) * C-c C-c: Plain lists. (line 74) @@ -6581,9 +6633,11 @@ Key Index * C-c C-o: Handling links. (line 58) * C-c C-p: Motion. (line 9) * C-c C-q <1>: Editing and debugging formulas. - (line 34) + (line 50) * C-c C-q: Built-in table editor. (line 125) +* C-c C-r <1>: Editing and debugging formulas. + (line 53) * C-c C-r: Visibility cycling. (line 34) * C-c C-s <1>: Agenda commands. (line 155) * C-c C-s: Creating timestamps. (line 48) @@ -6623,18 +6677,18 @@ Key Index * C-c l: Handling links. (line 9) * C-c { <1>: CDLaTeX mode. (line 21) * C-c {: Editing and debugging formulas. - (line 60) + (line 33) * C-c |: Built-in table editor. (line 40) * C-c }: Editing and debugging formulas. - (line 56) + (line 28) * C-c ~: Cooperation. (line 50) * C-k: Agenda commands. (line 117) * C-TAB: ARCHIVE tag. (line 38) * C-u C-c *: Updating the table. (line 18) * C-u C-c .: Creating timestamps. (line 16) * C-u C-c = <1>: Editing and debugging formulas. - (line 10) + (line 14) * C-u C-c =: Field formulas. (line 24) * C-u C-c C-c: Updating the table. (line 19) * C-u C-c C-l: Handling links. (line 43) @@ -6644,7 +6698,9 @@ Key Index * C-u C-c C-x C-u: Clocking work time. (line 70) * C-u C-u C-c *: Updating the table. (line 24) * C-u C-u C-c =: Editing and debugging formulas. - (line 14) + (line 18) +* C-x C-s: Editing and debugging formulas. + (line 46) * D: Agenda commands. (line 74) * d: Agenda commands. (line 71) * f: Agenda commands. (line 44) @@ -6656,7 +6712,7 @@ Key Index * L: Agenda commands. (line 32) * M: Agenda commands. (line 204) * M- <1>: Editing and debugging formulas. - (line 52) + (line 76) * M-: Built-in table editor. (line 82) * M- <1>: Built-in table editor. @@ -6671,14 +6727,16 @@ Key Index * M- <2>: Setting tags. (line 6) * M- <3>: Per file keywords. (line 17) * M-: Editing and debugging formulas. - (line 44) + (line 64) * M- <1>: Editing and debugging formulas. - (line 52) + (line 76) * M-: Built-in table editor. (line 82) -* M-S- <1>: Built-in table editor. +* M-S- <1>: Editing and debugging formulas. + (line 72) +* M-S- <2>: Built-in table editor. (line 89) -* M-S- <2>: Plain lists. (line 59) +* M-S- <3>: Plain lists. (line 59) * M-S-: Structure editing. (line 36) * M-S- <1>: The date/time prompt. (line 54) @@ -6695,9 +6753,11 @@ Key Index (line 79) * M-S- <3>: Plain lists. (line 65) * M-S-: Structure editing. (line 30) -* M-S- <1>: Built-in table editor. +* M-S- <1>: Editing and debugging formulas. + (line 72) +* M-S- <2>: Built-in table editor. (line 86) -* M-S- <2>: Plain lists. (line 59) +* M-S- <3>: Plain lists. (line 59) * M-S-: Structure editing. (line 33) * mouse-1 <1>: Agenda commands. (line 35) * mouse-1 <2>: The date/time prompt. @@ -6723,20 +6783,24 @@ Key Index * S- <3>: Creating timestamps. (line 58) * S- <4>: Priorities. (line 25) * S- <5>: Editing and debugging formulas. - (line 47) + (line 67) * S-: Plain lists. (line 55) * S- <1>: Agenda commands. (line 169) * S- <2>: The date/time prompt. (line 42) * S- <3>: Creating timestamps. (line 53) -* S-: TODO basics. (line 20) +* S- <4>: TODO basics. (line 20) +* S-: Editing and debugging formulas. + (line 67) * S-: Built-in table editor. (line 146) * S- <1>: Agenda commands. (line 161) * S- <2>: The date/time prompt. (line 39) * S- <3>: Creating timestamps. (line 53) -* S-: TODO basics. (line 20) +* S- <4>: TODO basics. (line 20) +* S-: Editing and debugging formulas. + (line 67) * S- <1>: Built-in table editor. (line 61) * S-: Visibility cycling. (line 22) @@ -6746,7 +6810,7 @@ Key Index * S- <3>: Creating timestamps. (line 58) * S- <4>: Priorities. (line 25) * S- <5>: Editing and debugging formulas. - (line 47) + (line 67) * S-: Plain lists. (line 55) * T: Agenda commands. (line 126) * t: Agenda commands. (line 113) @@ -6758,181 +6822,182 @@ Key Index  Tag Table: Node: Top970 -Node: Introduction11398 -Node: Summary11813 -Node: Installation14821 -Node: Activation16199 -Node: Feedback17448 -Node: Document structure19524 -Node: Outlines20298 -Node: Headlines20958 -Node: Visibility cycling21581 -Ref: Visibility cycling-Footnote-123795 -Ref: Visibility cycling-Footnote-223853 -Ref: Visibility cycling-Footnote-323903 -Node: Motion24172 -Node: Structure editing24956 -Node: Archiving27782 -Node: ARCHIVE tag28340 -Node: Moving subtrees30133 -Node: Sparse trees31444 -Ref: Sparse trees-Footnote-133576 -Ref: Sparse trees-Footnote-233758 -Node: Plain lists33873 -Ref: Plain lists-Footnote-137398 -Ref: Plain lists-Footnote-237755 -Node: Tables37939 -Node: Built-in table editor38453 -Node: Narrow columns45449 -Ref: Narrow columns-Footnote-147381 -Node: orgtbl-mode47427 -Node: The spreadsheet48231 -Node: References49049 -Node: Formula syntax for Calc52684 -Node: Formula syntax for Lisp55001 -Node: Field formulas56229 -Node: Column formulas57540 -Node: Editing and debugging formulas58963 -Node: Updating the table62328 -Node: Advanced features63359 -Node: Hyperlinks67884 -Node: Link format68657 -Node: Internal links69950 -Ref: Internal links-Footnote-171875 -Node: Radio targets72007 -Node: External links72698 -Node: Handling links75102 -Ref: Handling links-Footnote-180194 -Ref: Handling links-Footnote-280431 -Node: Link abbreviations80505 -Node: Search options82184 -Ref: Search options-Footnote-183964 -Node: Custom searches84045 -Node: Remember85093 -Node: Setting up remember86080 -Node: Remember templates86662 -Ref: Remember templates-Footnote-189977 -Node: Storing notes90075 -Node: TODO items91883 -Node: TODO basics92865 -Node: TODO extensions94392 -Node: Workflow states95187 -Node: TODO types96172 -Ref: TODO types-Footnote-197830 -Node: Per file keywords97912 -Ref: Per file keywords-Footnote-199366 -Node: Priorities99567 -Node: Breaking down tasks100811 -Ref: Breaking down tasks-Footnote-1101330 -Node: Checkboxes101426 -Node: Timestamps104181 -Node: Time stamps104715 -Ref: Time stamps-Footnote-1108209 -Ref: Time stamps-Footnote-2108325 -Node: Creating timestamps108480 -Node: The date/time prompt111106 -Ref: The date/time prompt-Footnote-1113067 -Node: Custom time format113173 -Node: Repeating items114731 -Node: Progress logging116541 -Node: Closing items117187 -Ref: Closing items-Footnote-1118121 -Ref: Closing items-Footnote-2118190 -Node: Tracking TODO state changes118263 -Node: Clocking work time119119 -Ref: Clocking work time-Footnote-1122765 -Ref: Clocking work time-Footnote-2122843 -Node: Tags122969 -Node: Tag inheritance123731 -Node: Setting tags124668 -Ref: Setting tags-Footnote-1129191 -Ref: Setting tags-Footnote-2129303 -Node: Tag searches129386 -Node: Agenda views132097 -Node: Agenda files134042 -Ref: Agenda files-Footnote-1135008 -Ref: Agenda files-Footnote-2135157 -Node: Agenda dispatcher135350 -Node: Built-in agenda views137041 -Node: Weekly/Daily agenda137619 -Node: Global TODO list139748 -Node: Matching headline tags141921 -Node: Timeline142992 -Node: Stuck projects143658 -Node: Presentation and sorting145357 -Node: Categories146148 -Node: Time-of-day specifications146812 -Node: Sorting of agenda items148783 -Node: Agenda commands150065 -Node: Custom agenda views156718 -Node: Storing searches157393 -Node: Block agenda159305 -Node: Setting Options160535 -Node: Batch processing163247 -Node: Embedded LaTeX164377 -Ref: Embedded LaTeX-Footnote-1165469 -Node: Math symbols165659 -Node: Subscripts and Superscripts166424 -Node: LaTeX fragments167268 -Ref: LaTeX fragments-Footnote-1169376 -Node: Processing LaTeX fragments169638 -Node: CDLaTeX mode170584 -Ref: CDLaTeX mode-Footnote-1173068 -Node: Exporting173216 -Node: ASCII export174530 -Node: HTML export175820 -Node: Export commands176439 -Node: Quoting HTML tags177163 -Node: Links177793 -Node: Images178490 -Ref: Images-Footnote-1179361 -Node: CSS support179422 -Ref: CSS support-Footnote-1180741 -Node: XOXO export180854 -Node: iCalendar export181293 -Node: Text interpretation182512 -Node: Comment lines182991 -Node: Enhancing text183462 -Node: Export options185280 -Node: Publishing186977 -Ref: Publishing-Footnote-1187773 -Node: Configuration187969 -Node: Project alist188687 -Node: Sources and destinations189753 -Node: Selecting files190483 -Node: Publishing action191231 -Node: Publishing options192464 -Node: Publishing links194616 -Node: Project page index196129 -Node: Sample configuration196907 -Node: Simple example197399 -Node: Complex example198072 -Node: Triggering publication200148 -Node: Miscellaneous200833 -Node: Completion201467 -Node: Customization202938 -Node: In-buffer settings203521 -Node: The very busy C-c C-c key207761 -Node: Clean view209405 -Node: TTY keys211982 -Node: Interaction213591 -Node: Cooperation213988 -Node: Conflicts216728 -Node: Bugs218320 -Node: Extensions and Hacking219816 -Node: Extensions220412 -Node: Tables in arbitrary syntax222359 -Node: Radio tables223436 -Node: A LaTeX example225939 -Ref: A LaTeX example-Footnote-1229585 -Ref: A LaTeX example-Footnote-2229733 -Node: Translator functions230168 -Ref: Translator functions-Footnote-1233277 -Node: Dynamic blocks233365 -Node: Special agenda views235337 -Ref: Special agenda views-Footnote-1237616 -Node: History and Acknowledgments237876 -Node: Index243665 -Node: Key Index274359 +Node: Introduction11399 +Node: Summary11814 +Node: Installation14823 +Node: Activation16201 +Node: Feedback17450 +Node: Document structure19526 +Node: Outlines20300 +Node: Headlines20960 +Node: Visibility cycling21583 +Ref: Visibility cycling-Footnote-123797 +Ref: Visibility cycling-Footnote-223855 +Ref: Visibility cycling-Footnote-323905 +Node: Motion24174 +Node: Structure editing24958 +Node: Archiving27784 +Node: ARCHIVE tag28342 +Node: Moving subtrees30135 +Node: Sparse trees31446 +Ref: Sparse trees-Footnote-133578 +Ref: Sparse trees-Footnote-233760 +Node: Plain lists33875 +Ref: Plain lists-Footnote-137400 +Ref: Plain lists-Footnote-237757 +Node: Tables37941 +Node: Built-in table editor38455 +Node: Narrow columns45451 +Ref: Narrow columns-Footnote-147384 +Node: orgtbl-mode47430 +Node: The spreadsheet48234 +Node: References49321 +Ref: References-Footnote-153370 +Node: Formula syntax for Calc53659 +Node: Formula syntax for Lisp56125 +Node: Field formulas57394 +Node: Column formulas58702 +Node: Editing and debugging formulas60301 +Node: Updating the table64454 +Node: Advanced features65485 +Node: Hyperlinks70010 +Node: Link format70783 +Node: Internal links72076 +Ref: Internal links-Footnote-174001 +Node: Radio targets74133 +Node: External links74824 +Node: Handling links77228 +Ref: Handling links-Footnote-182320 +Ref: Handling links-Footnote-282557 +Node: Link abbreviations82631 +Node: Search options84310 +Ref: Search options-Footnote-186090 +Node: Custom searches86171 +Node: Remember87219 +Node: Setting up remember88206 +Node: Remember templates88788 +Ref: Remember templates-Footnote-192102 +Node: Storing notes92200 +Node: TODO items94008 +Node: TODO basics94991 +Node: TODO extensions96518 +Node: Workflow states97313 +Node: TODO types98298 +Ref: TODO types-Footnote-199956 +Node: Per file keywords100038 +Ref: Per file keywords-Footnote-1101492 +Node: Priorities101693 +Node: Breaking down tasks102937 +Ref: Breaking down tasks-Footnote-1103457 +Node: Checkboxes103553 +Node: Timestamps106308 +Node: Time stamps106842 +Ref: Time stamps-Footnote-1110336 +Ref: Time stamps-Footnote-2110452 +Node: Creating timestamps110607 +Node: The date/time prompt113243 +Ref: The date/time prompt-Footnote-1115204 +Node: Custom time format115310 +Node: Repeating items116868 +Node: Progress logging118678 +Node: Closing items119324 +Ref: Closing items-Footnote-1120258 +Ref: Closing items-Footnote-2120327 +Node: Tracking TODO state changes120400 +Node: Clocking work time121256 +Ref: Clocking work time-Footnote-1124902 +Ref: Clocking work time-Footnote-2124980 +Node: Tags125106 +Node: Tag inheritance125868 +Node: Setting tags126805 +Ref: Setting tags-Footnote-1131328 +Ref: Setting tags-Footnote-2131440 +Node: Tag searches131523 +Node: Agenda views134234 +Node: Agenda files136179 +Ref: Agenda files-Footnote-1137145 +Ref: Agenda files-Footnote-2137294 +Node: Agenda dispatcher137487 +Node: Built-in agenda views139178 +Node: Weekly/Daily agenda139756 +Node: Global TODO list141885 +Node: Matching headline tags144058 +Node: Timeline145129 +Node: Stuck projects145795 +Node: Presentation and sorting147494 +Node: Categories148285 +Node: Time-of-day specifications148949 +Node: Sorting of agenda items150920 +Node: Agenda commands152202 +Node: Custom agenda views158855 +Node: Storing searches159530 +Node: Block agenda161442 +Node: Setting Options162672 +Node: Batch processing165384 +Node: Embedded LaTeX166514 +Ref: Embedded LaTeX-Footnote-1167606 +Node: Math symbols167796 +Node: Subscripts and Superscripts168561 +Node: LaTeX fragments169405 +Ref: LaTeX fragments-Footnote-1171513 +Node: Processing LaTeX fragments171775 +Node: CDLaTeX mode172721 +Ref: CDLaTeX mode-Footnote-1175205 +Node: Exporting175353 +Node: ASCII export176667 +Node: HTML export177957 +Node: Export commands178576 +Node: Quoting HTML tags179300 +Node: Links179930 +Node: Images180627 +Ref: Images-Footnote-1181498 +Node: CSS support181559 +Ref: CSS support-Footnote-1182878 +Node: XOXO export182991 +Node: iCalendar export183430 +Node: Text interpretation184649 +Node: Comment lines185128 +Node: Enhancing text185599 +Node: Export options187417 +Node: Publishing189114 +Ref: Publishing-Footnote-1189910 +Node: Configuration190106 +Node: Project alist190824 +Node: Sources and destinations191890 +Node: Selecting files192620 +Node: Publishing action193368 +Node: Publishing options194601 +Node: Publishing links196753 +Node: Project page index198266 +Node: Sample configuration199044 +Node: Simple example199536 +Node: Complex example200209 +Node: Triggering publication202285 +Node: Miscellaneous202970 +Node: Completion203604 +Node: Customization205075 +Node: In-buffer settings205658 +Node: The very busy C-c C-c key210135 +Node: Clean view211779 +Node: TTY keys214356 +Node: Interaction215965 +Node: Cooperation216362 +Node: Conflicts219102 +Node: Bugs220694 +Node: Extensions and Hacking222190 +Node: Extensions222786 +Node: Tables in arbitrary syntax224733 +Node: Radio tables225810 +Node: A LaTeX example228313 +Ref: A LaTeX example-Footnote-1231959 +Ref: A LaTeX example-Footnote-2232107 +Node: Translator functions232542 +Ref: Translator functions-Footnote-1235651 +Node: Dynamic blocks235739 +Node: Special agenda views237711 +Ref: Special agenda views-Footnote-1239990 +Node: History and Acknowledgments240250 +Node: Index246039 +Node: Key Index276879  End Tag Table diff --git a/org.el b/org.el index 313748e8e..ee73a2646 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.67 +;; Version: 4.68 ;; ;; This file is part of GNU Emacs. ;; @@ -83,7 +83,7 @@ ;;; Version -(defvar org-version "4.67" +(defconst org-version "4.68" "The version number of the file org.el.") (defun org-version () (interactive) @@ -783,6 +783,18 @@ calls `table-recognize-table'." :tag "Org Table Calculation" :group 'org-table) +(defcustom org-table-use-standard-references t + "Should org-mode work with table refrences like B3 instead of @3$2? +Possible values are: +nil never use them +from accept as input, do not present for editing +t: accept as input and present for editing" + :group 'org-table-calculation + :type '(choice + (const :tag "Never, don't even check unser input for them" nil) + (const :tag "Always, both as user input, and when editing" t) + (const :tag "Conver user input, don't offerr during editing" 'from))) + (defcustom org-table-copy-increment t "Non-nil means, increment when copying current field with \\[org-table-copy-down]." :group 'org-table-calculation @@ -815,9 +827,6 @@ the command \\[org-table-eval-formula]." :group 'org-table-calculation :type 'boolean) -;; FIXME this is also a variable that makes Org-mode files non-portable -;; Maybe I should have a #+ options for constants? -;; How about the SI/cgs issue? (defcustom org-table-formula-use-constants t "Non-nil means, interpret constants in formulas in tables. A constant looks like `$c' or `$Grav' and will be replaced before evaluation @@ -826,6 +835,8 @@ from the `constants.el' package." :group 'org-table-calculation :type 'boolean) +;; FIXME this is also a variable that makes Org-mode files non-portable +;; Maybe I should have a #+ options for constants? (defcustom org-table-formula-constants nil "Alist with constant names and values, for use in table formulas. The car of each element is a name of a constant, without the `$' before it. @@ -1332,6 +1343,7 @@ Changes become only effective after restarting Emacs." :group 'org-keywords :type '(repeat (string :tag "Keyword"))) +;; FIXME: remove priority as a possible value, this seems to be obsolete. (defcustom org-todo-interpretation 'sequence "Controls how TODO keywords are interpreted. This variable is only relevant if `org-todo-keywords' contains more than two @@ -2006,7 +2018,7 @@ a grid line." (defcustom org-agenda-sorting-strategy '((agenda time-up category-keep priority-down) (todo category-keep priority-down) - (tags category-keep)) + (tags category-keep priority-down)) "Sorting structure for the agenda items of a single day. This is a list of symbols which will be used in sequence to determine if an entry should be listed before another entry. The following @@ -3102,6 +3114,12 @@ Also put tags into group 4 if tags are present.") ((assoc key option) (cdr (assoc key option))) (t (cdr (assq 'default option))))) +(defsubst org-inhibit-invisibility () + "Modified `buffer-invisibility-spec' for Emacs 21. +Some ops with invisible text do not work correctly on Emacs 21. For these +we turn off invisibility temporarily. Use this in a `let' form." + (if (< emacs-major-version 22) nil buffer-invisibility-spec)) + (defsubst org-set-local (var value) "Make VAR local in current buffer and set it to VALUE." (set (make-variable-buffer-local var) value)) @@ -3139,7 +3157,9 @@ Also put tags into group 4 if tags are present.") ("nologging" org-log-done nil) ("lognotedone" org-log-done done push) ("lognotestate" org-log-done state push) - ("lognoteclock-out" org-log-done clock-out push)) + ("lognoteclock-out" org-log-done clock-out push) + ("constcgs" constants-unit-system cgs) + ("constSI" constants-unit-system SI)) "Variable associated with STARTUP options for org-mode. Each element is a list of three items: The startup options as written in the #+STARTUP line, the corresponding variable, and the value to @@ -3184,14 +3204,15 @@ means to push this value onto the list in the variable.") ((equal key "STARTUP") (let ((opts (org-split-string value splitre)) l var val) - (while (setq l (assoc (pop opts) org-startup-options)) - (setq var (nth 1 l) val (nth 2 l)) - (if (not (nth 3 l)) - (set (make-local-variable var) val) - (if (not (listp (symbol-value var))) - (set (make-local-variable var) nil)) - (set (make-local-variable var) (symbol-value var)) - (add-to-list var val))))) + (while (setq l (pop opts)) + (when (setq l (assoc l org-startup-options)) + (setq var (nth 1 l) val (nth 2 l)) + (if (not (nth 3 l)) + (set (make-local-variable var) val) + (if (not (listp (symbol-value var))) + (set (make-local-variable var) nil)) + (set (make-local-variable var) (symbol-value var)) + (add-to-list var val)))))) ((equal key "ARCHIVE") (string-match " *$" value) (setq arch (replace-match "" t t value)) @@ -3325,6 +3346,7 @@ This is for getting out of special buffers like remember.") (defvar annotation) ; from remember.el, dynamically scoped in `remember-mode' (defvar initial) ; from remember.el, dynamically scoped in `remember-mode' (defvar org-latex-regexps) +(defvar constants-unit-system) (defvar original-date) ; dynamically scoped in calendar.el does scope this @@ -3521,7 +3543,6 @@ The following commands are available: (when (featurep 'xemacs) (org-set-local 'line-move-ignore-invisible t)) (setq outline-regexp "\\*+") - ;;(setq outline-regexp "\\(?:\\*+\\|[ \t]*\\(?:[-+*]\\|[0-9]+[.)]\\) \\)") (setq outline-level 'org-outline-level) (when (and org-ellipsis (stringp org-ellipsis) (fboundp 'set-display-table-slot) (boundp 'buffer-display-table)) @@ -3534,6 +3555,7 @@ The following commands are available: ;; Calc embedded (org-set-local 'calc-embedded-open-mode "# ") (modify-syntax-entry ?# "<") + (modify-syntax-entry ?@ "w") (if org-startup-truncated (setq truncate-lines t)) (org-set-local 'font-lock-unfontify-region-function 'org-unfontify-region) @@ -3545,6 +3567,7 @@ The following commands are available: (org-add-hook 'kill-buffer-hook 'org-check-running-clock nil 'local) ;; Paragraphs and auto-filling (org-set-autofill-regexps) + (setq indent-line-function 'org-indent-line-function) (org-update-radio-target-regexp) ;; Comment characters @@ -3912,6 +3935,7 @@ between words." (if (memq 'radio lk) '(org-activate-target-links (0 'org-link t))) (if (memq 'date lk) '(org-activate-dates (0 'org-date t))) (if (memq 'tag lk) '(org-activate-tags (1 'org-tag prepend))) + '(org-hide-wide-columns (0 nil append)) ;; TODO lines (list (concat "^\\*+[ \t]*" org-not-done-regexp) '(1 'org-todo t)) @@ -4473,10 +4497,13 @@ the current headline." pos) (cond ((and (org-on-heading-p) (bolp) - (save-excursion (backward-char 1) (not (org-invisible-p)))) + (or (bobp) + (save-excursion (backward-char 1) (not (org-invisible-p))))) (open-line (if blank 2 1))) - ((and (bolp) (save-excursion - (backward-char 1) (not (org-invisible-p)))) + ((and (bolp) + (or (bobp) + (save-excursion + (backward-char 1) (not (org-invisible-p))))) nil) (t (newline (if blank 2 1)))) (insert head) (just-one-space) @@ -5129,7 +5156,7 @@ with the current numbers. With optional prefix argument ALL, do this for the whole buffer." (interactive "P") (save-excursion - (let* ((buffer-invisibility-spec nil) ; Emacs 21 compatibility + (let* ((buffer-invisibility-spec (org-inhibit-invisibility)) ; Emacs 21 (beg (progn (outline-back-to-heading) (point))) (end (move-marker (make-marker) (progn (outline-next-heading) (point)))) @@ -5528,9 +5555,10 @@ this heading. " (org-done-string tr-org-done-string) (org-todo-regexp tr-org-todo-regexp) (org-todo-line-regexp tr-org-todo-line-regexp) - (org-odd-levels-only (if (local-variable-p org-odd-levels-only) - org-odd-levels-only - tr-org-odd-levels-only))) + (org-odd-levels-only + (if (local-variable-p 'org-odd-levels-only (current-buffer)) + org-odd-levels-only + tr-org-odd-levels-only))) (goto-char (point-min)) (if heading (progn @@ -5651,7 +5679,7 @@ When TAG is non-nil, don't move trees, but mark them with the ARCHIVE tag." (defun org-toggle-tag (tag &optional onoff) "Toggle the tag TAG for the current line. If ONOFF is `on' or `off', don't toggle but set to this state." - (unless (org-on-heading-p) (error "Not on headling")) + (unless (org-on-heading-p t) (error "Not on headling")) (let (res current) (save-excursion (beginning-of-line) @@ -5747,6 +5775,8 @@ outside the table.") "Table row types, non-nil only for the duration of a comand.") (defvar org-table-current-begin-line nil "Table begin line, non-nil only for the duration of a comand.") +(defvar org-table-current-begin-pos nil + "Table begin position, non-nil only for the duration of a comand.") (defvar org-table-dlines nil "Vector of data line line numbers in the current table.") (defvar org-table-hlines nil @@ -5758,11 +5788,17 @@ outside the table.") "Regular expression for matching ranges in formulas.") (defconst org-table-range-regexp2 - "@\\([-+]?I*[-+]?[0-9]*\\)?\\(\\$[-+]?[a-zA-Z0-9]+\\)?\\(\\.\\.@?\\([-+]?I*[-+]?[0-9]*\\)?\\(\\$[-+]?[a-zA-Z0-9]+\\)?\\)?\\|\\$[a-zA-Z0-9]+\\.\\.\\$[a-zA-Z0-9]+" - "Regular expression to recognize ranges in formulas for highlighting.") + (concat + "\\(" "@[-0-9I$&]+" "\\|" "[a-zA-Z]\\{1,2\\}\\([0-9]+\\|&\\)" "\\|" "\\$[a-zA-Z0-9]+" "\\)" + "\\.\\." + "\\(" "@?[-0-9I$&]+" "\\|" "[a-zA-Z]\\{1,2\\}\\([0-9]+\\|&\\)" "\\|" "\\$[a-zA-Z0-9]+" "\\)") + "Match a range for reference display.") -(defvar org-inhibit-highlight-removal nil) +(defconst org-table-translate-regexp + (concat "\\(" "@[-0-9I$]+" "\\|" "[a-zA-Z]\\{1,2\\}\\([0-9]+\\|&\\)" "\\)") + "Match a reference that needs translation, for reference display.") +(defvar org-inhibit-highlight-removal nil) ; dynamically scoped param (defun org-table-create-with-table.el () "Use the table.el package to insert a new table. @@ -6323,7 +6359,7 @@ is always the old value." (let* ((pos (match-beginning 0)) (val (buffer-substring (1+ pos) (match-end 0)))) (if replace - (replace-match (concat "|" replace))) + (replace-match (concat "|" replace) t t)) (goto-char (min (point-at-eol) (+ 2 pos))) val) (forward-char 1) "")) @@ -6342,21 +6378,26 @@ is always the old value." (eql (org-table-get-stored-formulas)) (dline (org-table-current-dline)) (ref (format "@%d$%d" dline col)) + (ref1 (org-table-convert-refs-to-an ref)) (fequation (or (assoc name eql) (assoc ref eql))) - (cequation (assoc (int-to-string col) eql))) + (cequation (assoc (int-to-string col) eql)) + (eqn (or fequation cequation))) (goto-char pos) (condition-case nil - (org-show-reference 'local) + (org-table-show-reference 'local) (error nil)) - (message "line @%d, col $%s%s, ref @%d$%d%s%s" + (message "line @%d, col $%s%s, ref @%d$%d or %s%s%s" dline col (if cname (concat " or $" cname) "") - dline col + dline col ref1 (if name (concat " or $" name) "") ;; FIXME: formula info not correct if special table line - (if (or fequation cequation) - (concat ", " (if fequation "field" "column") - " formula applies" "") + (if eqn + (concat ", formula: " + (org-table-formula-to-user + (concat + (if (string-match "^[$@]"(car eqn)) "" "$") + (car eqn) "=" (cdr eqn)))) ""))))) (defun org-table-current-column () @@ -7157,21 +7198,25 @@ If NLAST is a number, only the NLAST fields will actually be summed." ((equal n 0) nil) (t n)))) -(defun org-table-current-field-formula () +(defun org-table-current-field-formula (&optional key noerror) "Return the formula active for the current field. -Assumes that specials are in place." +Assumes that specials are in place. +If KEY is given, return the key to this formula. +Otherwise return the formula preceeded with \"=\" or \":=\"." (let* ((name (car (rassoc (list (org-current-line) (org-table-current-column)) org-table-named-field-locations))) (col (org-table-current-column)) (scol (int-to-string col)) (ref (format "@%d$%d" (org-table-current-dline) col)) - (stored-list (org-table-get-stored-formulas)) + (stored-list (org-table-get-stored-formulas noerror)) (ass (or (assoc name stored-list) (assoc ref stored-list) (assoc scol stored-list)))) - (if ass (concat (if (string-match "^[0-9]+$" (car ass)) "=" ":=") - (cdr ass))))) + (if key + (car ass) + (if ass (concat (if (string-match "^[0-9]+$" (car ass)) "=" ":=") + (cdr ass)))))) (defun org-table-get-formula (&optional equation named) "Read a formula from the minibuffer, offer stored formula as default. @@ -7197,11 +7242,16 @@ When NAMED is non-nil, look for a named equation." stored) ((stringp equation) equation) - (t (read-string - (format "%s formula $%s=" (if named "Field" "Column") scol) - (or stored "") 'org-table-formula-history - ;stored - )))) + (t (org-table-formula-from-user + (read-string + (org-table-formula-to-user + (format "%s formula %s%s=" + (if named "Field" "Column") + (if (member (string-to-char scol) '(?$ ?@)) "" "$") + scol)) + (if stored (org-table-formula-to-user stored) "") + 'org-table-formula-history + ))))) mustsave) (when (not (string-match "\\S-" eq)) ;; remove formula @@ -7223,7 +7273,7 @@ When NAMED is non-nil, look for a named equation." (defun org-table-store-formulas (alist) "Store the list of formulas below the current table." - (setq alist (sort alist (lambda (a b) (string< (car a) (car b))))) + (setq alist (sort alist 'org-table-formula-less-p)) (save-excursion (goto-char (org-table-end)) (if (looking-at "\\([ \t]*\n\\)*#\\+TBLFM:\\(.*\n?\\)") @@ -7240,7 +7290,20 @@ When NAMED is non-nil, look for a named equation." alist "::") "\n"))) -(defun org-table-get-stored-formulas () +(defsubst org-table-formula-make-cmp-string (a) + (when (string-match "^\\(@\\([0-9]+\\)\\)?\\(\\$?\\([0-9]+\\)\\)?\\(\\$?[a-zA-Z0-9]+\\)?" a) + (concat + (if (match-end 2) (format "@%05d" (string-to-number (match-string 2 a))) "") + (if (match-end 4) (format "$%05d" (string-to-number (match-string 4 a))) "") + (if (match-end 5) (concat "@@" (match-string 5 a)))))) + +(defun org-table-formula-less-p (a b) + "Compare two formulas for sorting." + (let ((as (org-table-formula-make-cmp-string (car a))) + (bs (org-table-formula-make-cmp-string (car b)))) + (and as bs (string< as bs)))) + +(defun org-table-get-stored-formulas (&optional noerror) "Return an alist with the stored formulas directly after current table." (interactive) (let (scol eq eq-alist strings string seen) @@ -7256,7 +7319,12 @@ When NAMED is non-nil, look for a named equation." eq (match-string 3 string) eq-alist (cons (cons scol eq) eq-alist)) (if (member scol seen) - (error "Double definition `$%s=' in TBLFM line, please fix by hand" scol) + (if noerror + (progn + (message "Double definition `$%s=' in TBLFM line, please fix by hand" scol) + (ding) + (sit-for 2)) + (error "Double definition `$%s=' in TBLFM line, please fix by hand" scol)) (push scol seen)))))) (nreverse eq-alist))) @@ -7295,6 +7363,7 @@ For all numbers larger than LIMIT, shift them by DELTA." org-table-local-parameters nil org-table-named-field-locations nil org-table-current-begin-line nil + org-table-current-begin-pos nil org-table-current-line-types nil) (goto-char beg) (when (re-search-forward "^[ \t]*| *! *\\(|.*\\)" end t) @@ -7332,6 +7401,7 @@ For all numbers larger than LIMIT, shift them by DELTA." ;; Analyse the line types (goto-char beg) (setq org-table-current-begin-line (org-current-line) + org-table-current-begin-pos (point) l org-table-current-begin-line) (while (looking-at "[ \t]*|\\(-\\)?") (push (if (match-end 1) 'hline 'dline) types) @@ -7362,7 +7432,8 @@ If yes, store the formula and apply it." eq (match-string 1 field)) (if (or (fboundp 'calc-eval) (equal (substring eq 0 (min 2 (length eq))) "'(")) - (org-table-eval-formula (if named '(4) nil) eq) + (org-table-eval-formula (if named '(4) nil) + (org-table-formula-from-user eq)) (error "Calc does not seem to be installed, and is needed to evaluate the formula")))))) (defvar org-recalc-commands nil @@ -7483,7 +7554,7 @@ formula is installed as valid in only this specific field. When called with two `C-u' prefixes, insert the active equation for the field back into the current field, so that it can be -edited there. This is useful in order to use \\[org-show-reference] +edited there. This is useful in order to use \\[org-table-show-reference] to check the referenced fields. When called, the command first prompts for a formula, which is read in @@ -7594,17 +7665,16 @@ not overwrite the stored one." t t form))) (setq form0 form) ;; Insert the references to fields in same row - (while (string-match "\\$\\([0-9]+\\)?" form) - (setq n (if (match-beginning 1) - (string-to-number (match-string 1 form)) - n0) - x (nth (1- n) fields)) + (while (string-match "\\$\\([0-9]+\\)" form) + (setq n (string-to-number (match-string 1 form)) + x (nth (1- (if (= n 0) n0 n)) fields)) (unless x (error "Invalid field specifier \"%s\"" (match-string 0 form))) (setq form (replace-match (save-match-data (org-table-make-reference x nil numbers lispp)) t t form))) + (if lispp (setq ev (condition-case nil (eval (eval (read form))) @@ -7922,69 +7992,121 @@ Parameters get priority." (and (fboundp 'constants-get) (constants-get const)) "#UNDEFINED_NAME")) -(defvar org-edit-formulas-map (make-sparse-keymap)) -(define-key org-edit-formulas-map "\C-c\C-c" 'org-finish-edit-formulas) -(define-key org-edit-formulas-map "\C-c\C-q" 'org-abort-edit-formulas) -(define-key org-edit-formulas-map "\C-c?" 'org-show-reference) -(define-key org-edit-formulas-map [(shift up)] 'org-table-edit-line-up) -(define-key org-edit-formulas-map [(shift down)] 'org-table-edit-line-down) -(define-key org-edit-formulas-map [(shift left)] 'org-table-edit-backward-field) -(define-key org-edit-formulas-map [(shift right)] 'org-table-edit-next-field) -(define-key org-edit-formulas-map [(meta up)] 'org-table-edit-scroll-down) -(define-key org-edit-formulas-map [(meta down)] 'org-table-edit-scroll) -(define-key org-edit-formulas-map [(meta tab)] 'lisp-complete-symbol) -(define-key org-edit-formulas-map "\M-\C-i" 'lisp-complete-symbol) -(define-key org-edit-formulas-map [(tab)] 'org-edit-formula-lisp-indent) -(define-key org-edit-formulas-map "\C-i" 'org-edit-formula-lisp-indent) +(defvar org-table-fedit-map (make-sparse-keymap)) +(define-key org-table-fedit-map "\C-x\C-s" 'org-table-fedit-finish) +(define-key org-table-fedit-map "\C-c\C-s" 'org-table-fedit-finish) +(define-key org-table-fedit-map "\C-c\C-c" 'org-table-fedit-finish) +(define-key org-table-fedit-map "\C-c\C-q" 'org-table-fedit-abort) +(define-key org-table-fedit-map "\C-c?" 'org-table-show-reference) +(define-key org-table-fedit-map [(meta shift up)] 'org-table-fedit-line-up) +(define-key org-table-fedit-map [(meta shift down)] 'org-table-fedit-line-down) +(define-key org-table-fedit-map [(shift up)] 'org-table-fedit-ref-up) +(define-key org-table-fedit-map [(shift down)] 'org-table-fedit-ref-down) +(define-key org-table-fedit-map [(shift left)] 'org-table-fedit-ref-left) +(define-key org-table-fedit-map [(shift right)] 'org-table-fedit-ref-right) +(define-key org-table-fedit-map [(meta up)] 'org-table-fedit-scroll-down) +(define-key org-table-fedit-map [(meta down)] 'org-table-fedit-scroll) +(define-key org-table-fedit-map [(meta tab)] 'lisp-complete-symbol) +(define-key org-table-fedit-map "\M-\C-i" 'lisp-complete-symbol) +(define-key org-table-fedit-map [(tab)] 'org-table-fedit-lisp-indent) +(define-key org-table-fedit-map "\C-i" 'org-table-fedit-lisp-indent) +(define-key org-table-fedit-map "\C-c\C-r" 'org-table-fedit-toggle-ref-type) +(define-key org-table-fedit-map "\C-c}" 'org-table-fedit-toggle-coordinates) + +(easy-menu-define org-table-fedit-menu org-table-fedit-map "Org Edit Formulas Menu" + '("Edit-Formulas" + ["Finish and Install" org-table-fedit-finish t] + ["Finish, Install, and Apply" (org-table-fedit-finish t) :keys "C-u C-c C-c"] + ["Abort" org-table-fedit-abort t] + "--" + ["Pretty-Print Lisp Formula" org-table-fedit-lisp-indent t] + ["Complete Lisp Symbol" lisp-complete-symbol t] + "--" + "Shift Reference at Point" + ["Up" org-table-fedit-ref-up t] + ["Down" org-table-fedit-ref-down t] + ["Left" org-table-fedit-ref-left t] + ["Right" org-table-fedit-ref-right t] + "-" + "Change Test Row for Column Formulas" + ["Up" org-table-fedit-line-up t] + ["Down" org-table-fedit-line-down t] + "--" + ["Scroll Table Window" org-table-fedit-scroll t] + ["Scroll Table Window down" org-table-fedit-scroll-down t] + ["Show Table Grid" org-table-fedit-toggle-coordinates + :style toggle :selected (with-current-buffer (marker-buffer org-pos) + org-table-overlay-coordinates)] + "--" + ["Standard Refs (B3 instead of @3$2)" org-table-fedit-toggle-ref-type + :style toggle :selected org-table-buffer-is-an])) (defvar org-pos) (defun org-table-edit-formulas () "Edit the formulas of the current table in a separate buffer." (interactive) + (when (save-excursion (beginning-of-line 1) (looking-at "#\\+TBLFM")) + (beginning-of-line 0)) (unless (org-at-table-p) (error "Not at a table")) (org-table-get-specials) - (let ((eql (org-table-get-stored-formulas)) + (let ((key (org-table-current-field-formula 'key 'noerror)) + (eql (sort (org-table-get-stored-formulas 'noerror) + 'org-table-formula-less-p)) (pos (move-marker (make-marker) (point))) + (startline 1) (wc (current-window-configuration)) - entry s) + (titles '((column . "# Column Formulas\n") + (field . "# Field Formulas\n") + (named . "# Named Field Formulas\n"))) + entry s type title) (switch-to-buffer-other-window "*Edit Formulas*") (erase-buffer) (fundamental-mode) (org-set-local 'org-pos pos) (org-set-local 'org-window-configuration wc) - (use-local-map org-edit-formulas-map) - (org-add-hook 'post-command-hook 'org-table-edit-formulas-post-command t t) - (setq s "# `C-c C-c' to finish, `C-u C-c C-c' to also apply, `C-c C-q' to abort. -# `TAB' to pretty-print Lisp expressions, `M-TAB' to complete List symbols -# `M-up/down' to scroll table, `S-up/down' to change line for column formulas\n\n") - - (put-text-property 0 (length s) 'face 'font-lock-comment-face s) - (insert s) + (use-local-map org-table-fedit-map) + (org-add-hook 'post-command-hook 'org-table-fedit-post-command t t) + (easy-menu-add org-table-fedit-menu) + (setq startline (org-current-line)) (while (setq entry (pop eql)) + (setq type (cond + ((equal (string-to-char (car entry)) ?@) 'field) + ((string-match "^[0-9]" (car entry)) 'column) + (t 'named))) + (when (setq title (assq type titles)) + (or (bobp) (insert "\n")) + (insert (org-add-props (cdr title) nil 'face font-lock-comment-face)) + (setq titles (delq title titles))) + (if (equal key (car entry)) (setq startline (org-current-line))) (setq s (concat (if (equal (string-to-char (car entry)) ?@) "" "$") (car entry) " = " (cdr entry) "\n")) (remove-text-properties 0 (length s) '(face nil) s) (insert s)) - (goto-char (point-min)) - (message "Edit formulas and finish with `C-c C-c'."))) + (if (eq org-table-use-standard-references t) + (org-table-fedit-toggle-ref-type)) + (goto-line startline) + (message "Edit formulas and finish with `C-c C-c'. See menu for more commands."))) -(defun org-table-edit-formulas-post-command () +(defun org-table-fedit-post-command () (when (not (memq this-command '(lisp-complete-symbol))) (let ((win (selected-window))) (save-excursion (condition-case nil - (org-show-reference) + (org-table-show-reference) (error nil)) (select-window win))))) -(defun org-finish-edit-formulas (&optional arg) +(defun org-table-fedit-finish (&optional arg) "Parse the buffer for formula definitions and install them. With prefix ARG, apply the new formulas to the table." (interactive "P") (org-table-remove-rectangle-highlight) + (if org-table-use-standard-references + (progn + (org-table-fedit-convert-buffer 'org-table-convert-refs-to-rc) + (setq org-table-buffer-is-an nil))) (let ((pos org-pos) eql var form) - (setq org-pos nil) (goto-char (point-min)) (while (re-search-forward "^\\(@[0-9]+\\$[0-9]+\\|\\$\\([a-zA-Z0-9]+\\)\\) *= *\\(.*\\(\n[ \t]+.*$\\)*\\)" @@ -7992,9 +8114,13 @@ With prefix ARG, apply the new formulas to the table." (setq var (if (match-end 2) (match-string 2) (match-string 1)) form (match-string 3)) (setq form (org-trim form)) - (while (string-match "[ \t]*\n[ \t]*" form) - (setq form (replace-match " " t t form))) - (push (cons var form) eql)) + (when (not (equal form "")) + (while (string-match "[ \t]*\n[ \t]*" form) + (setq form (replace-match " " t t form))) + (when (assoc var eql) + (error "Double formulas for %s" var)) + (push (cons var form) eql))) + (setq org-pos nil) (set-window-configuration org-window-configuration) (select-window (get-buffer-window (marker-buffer pos))) (goto-char pos) @@ -8007,7 +8133,7 @@ With prefix ARG, apply the new formulas to the table." (org-table-recalculate 'all) (message "New formulas installed - press C-u C-c C-c to apply.")))) -(defun org-abort-edit-formulas () +(defun org-table-fedit-abort () "Abort editing formulas, without installing the changes." (interactive) (org-table-remove-rectangle-highlight) @@ -8018,7 +8144,7 @@ With prefix ARG, apply the new formulas to the table." (move-marker pos nil) (message "Formula editing aborted without installing changes"))) -(defun org-edit-formula-lisp-indent () +(defun org-table-fedit-lisp-indent () "Pretty-print and re-indent Lisp expressions in the Formula Editor." (interactive) (let ((pos (point)) beg end ind) @@ -8059,7 +8185,7 @@ With prefix ARG, apply the new formulas to the table." (defvar org-show-positions nil) -(defun org-show-reference (&optional local) +(defun org-table-show-reference (&optional local) "Show the location/value of the $ expression at point." (interactive) (org-table-remove-rectangle-highlight) @@ -8072,12 +8198,18 @@ With prefix ARG, apply the new formulas to the table." var name e what match dest) (if local (org-table-get-specials)) (setq what (cond - ((org-at-regexp-p org-table-range-regexp2) 'range) + ((or (org-at-regexp-p org-table-range-regexp2) + (org-at-regexp-p org-table-translate-regexp) + (org-at-regexp-p org-table-range-regexp)) + (setq match + (save-match-data + (org-table-convert-refs-to-rc (match-string 0)))) + 'range) ((org-at-regexp-p "\\$[a-zA-Z][a-zA-Z0-9]*") 'name) ((org-at-regexp-p "\\$[0-9]+") 'column) ((not local) nil) (t (error "No reference at point"))) - match (and what (match-string 0))) + match (and what (or match (match-string 0)))) (when (and match (not (equal (match-beginning 0) (point-at-bol)))) (org-table-add-rectangle-overlay (match-beginning 0) (match-end 0) 'secondary-selection)) @@ -8089,9 +8221,13 @@ With prefix ARG, apply the new formulas to the table." (setq match (org-table-formula-substitute-names match))) (unless local (save-excursion + (end-of-line 1) + (re-search-backward "^\\S-" nil t) (beginning-of-line 1) - (when (looking-at "\\(\\$[0-9a-zA-Z]+\\|@[0-9]+\\$[0-9]+\\)=") - (setq dest (match-string 1)) + (when (looking-at "\\(\\$[0-9a-zA-Z]+\\|@[0-9]+\\$[0-9]+\\|[a-zA-Z]+\\([0-9]+\\|&\\)\\) *=") + (setq dest + (save-match-data + (org-table-convert-refs-to-rc (match-string 1)))) (org-table-add-rectangle-overlay (match-beginning 1) (match-end 1) face2)))) (if (and (markerp pos) (marker-buffer pos)) @@ -8160,18 +8296,20 @@ With prefix ARG, apply the new formulas to the table." (message "Constant: $%s=%s in `org-table-formula-constants'." var (cdr e))) ((setq e (and (fboundp 'constants-get) (constants-get var))) - (message "Constant: $%s=%s, retrieved from `constants.el'." var e)) + (message "Constant: $%s=%s, from `constants.el'%s." + var e (format " (%s units)" constants-unit-system))) (t (error "Undefined name $%s" var))))) (goto-char pos) - (when org-show-positions + (when (and org-show-positions + (not (memq this-command '(org-table-fedit-scroll + org-table-fedit-scroll-down)))) (push pos org-show-positions) + (push org-table-current-begin-pos org-show-positions) (let ((min (apply 'min org-show-positions)) (max (apply 'max org-show-positions))) - (when (or (not (pos-visible-in-window-p min)) - (not (pos-visible-in-window-p max))) - (goto-char min) - (set-window-start (selected-window) (point-at-bol)) - (goto-char pos)))) + (goto-char min) (recenter 0) + (goto-char max) + (or (pos-visible-in-window-p max) (recenter -1)))) (select-window win)))) (defun org-table-force-dataline () @@ -8188,27 +8326,17 @@ With prefix ARG, apply the new formulas to the table." ((or p1 p2) (goto-char (or p1 p2))) (t (error "No table dataline around here")))))) -(defun org-table-edit-line-up () +(defun org-table-fedit-line-up () "Move cursor one line up in the window showing the table." (interactive) - (org-table-edit-move 'previous-line)) + (org-table-fedit-move 'previous-line)) -(defun org-table-edit-line-down () +(defun org-table-fedit-line-down () "Move cursor one line down in the window showing the table." (interactive) - (org-table-edit-move 'next-line)) + (org-table-fedit-move 'next-line)) -(defun org-table-edit-backward-field () - "Move cursor one field backward in the window showing the table." - (interactive) - (org-table-edit-move 'org-table-previous-field)) - -(defun org-table-edit-next-field () - "Move cursor one field forward in the window showing the table." - (interactive) - (org-table-edit-move 'org-table-next-field)) - -(defun org-table-edit-move (command) +(defun org-table-fedit-move (command) "Move the cursor in the window shoinw the table. Use COMMAND to do the motion, repeat if necessary to end up in a data line." (let ((org-table-allow-automatic-line-recalculation nil) @@ -8223,14 +8351,14 @@ Use COMMAND to do the motion, repeat if necessary to end up in a data line." (move-marker pos (point)) (select-window win))) -(defun org-table-edit-scroll (N) +(defun org-table-fedit-scroll (N) (interactive "p") (let ((other-window-scroll-buffer (marker-buffer org-pos))) (scroll-other-window N))) -(defun org-table-edit-scroll-down (N) +(defun org-table-fedit-scroll-down (N) (interactive "p") - (org-table-edit-scroll (- N))) + (org-table-fedit-scroll (- N))) (defvar org-table-rectangle-overlays nil) @@ -8285,7 +8413,7 @@ Use COMMAND to do the motion, repeat if necessary to end up in a data line." (mapc 'org-delete-overlay org-table-coordinate-overlays) (setq org-table-coordinate-overlays nil) (save-excursion - (let ((id 0) (ih 0) hline eol str ic ov beg) + (let ((id 0) (ih 0) hline eol s1 s2 str ic ov beg) (goto-char (org-table-begin)) (while (org-at-table-p) (setq eol (point-at-eol)) @@ -8294,15 +8422,18 @@ Use COMMAND to do the motion, repeat if necessary to end up in a data line." (setq hline (looking-at org-table-hline-regexp)) (setq str (if hline (format "I*%-2d" (setq ih (1+ ih))) (format "%4d" (setq id (1+ id))))) - (org-overlay-before-string ov str 'org-formula 'evaporate) + (org-overlay-before-string ov str 'org-special-keyword 'evaporate) (when hline (setq ic 0) - (while (re-search-forward "[+|]-+" eol t) + (while (re-search-forward "[+|]\\(-+\\)" eol t) (setq beg (1+ (match-beginning 0)) - str (concat "$" (int-to-string (setq ic (1+ ic))))) + ic (1+ ic) + s1 (concat "$" (int-to-string ic)) + s2 (org-number-to-letters ic) + str (if org-table-use-standard-references s2 s1)) (setq ov (org-make-overlay beg (+ beg (length str)))) (push ov org-table-coordinate-overlays) - (org-overlay-display ov str 'org-formula 'evaporate))) + (org-overlay-display ov str 'org-special-keyword 'evaporate))) (beginning-of-line 2))))) (defun org-table-toggle-coordinate-overlays () @@ -11430,7 +11561,7 @@ are included in the output." (case-fold-search nil) lspos tags tags-list tags-alist (llast 0) rtn level category i txt - todo marker entry) + todo marker entry priority) (save-excursion (goto-char (point-min)) (when (eq action 'sparse-tree) (org-overview)) @@ -11472,11 +11603,13 @@ are included in the output." (if org-tags-match-list-sublevels (make-string (1- level) ?.) "") (org-get-heading)) - category tags-list)) + category tags-list) + priority (org-get-priority txt)) (goto-char lspos) (setq marker (org-agenda-new-marker)) (org-add-props txt props - 'org-marker marker 'org-hd-marker marker 'org-category category) + 'org-marker marker 'org-hd-marker marker 'org-category category + 'priority priority) (push txt rtn)) ;; if we are to skip sublevels, jump to end of subtree (or org-tags-match-list-sublevels (org-end-of-subtree t)))))) @@ -11605,7 +11738,7 @@ With prefix ARG, realign all tags in headings in the current buffer." (if arg (save-excursion (goto-char (point-min)) - (let (buffer-invisibility-spec) ; Emacs 21 compatibility + (let ((buffer-invisibility-spec (org-inhibit-invisibility))) (while (re-search-forward re nil t) (org-set-tags nil t) (end-of-line 1))) @@ -11613,24 +11746,26 @@ With prefix ARG, realign all tags in headings in the current buffer." (if just-align (setq tags current) ;; Get a new set of tags from the user - (setq table (or org-tag-alist (org-get-buffer-tags)) - org-last-tags-completion-table table - current-tags (org-split-string current ":") - inherited-tags (nreverse - (nthcdr (length current-tags) - (nreverse (org-get-tags-at)))) - tags - (if (or (eq t org-use-fast-tag-selection) - (and org-use-fast-tag-selection - (delq nil (mapcar 'cdr table)))) - (org-fast-tag-selection current-tags inherited-tags table) - (let ((org-add-colon-after-tag-completion t)) - (org-trim - (completing-read "Tags: " 'org-tags-completion-function - nil nil current 'org-tags-history))))) + (save-excursion + (setq table (or org-tag-alist (org-get-buffer-tags)) + org-last-tags-completion-table table + current-tags (org-split-string current ":") + inherited-tags (nreverse + (nthcdr (length current-tags) + (nreverse (org-get-tags-at)))) + tags + (if (or (eq t org-use-fast-tag-selection) + (and org-use-fast-tag-selection + (delq nil (mapcar 'cdr table)))) + (org-fast-tag-selection current-tags inherited-tags table) + (let ((org-add-colon-after-tag-completion t)) + (org-trim + (completing-read "Tags: " 'org-tags-completion-function + nil nil current 'org-tags-history)))))) (while (string-match "[-+&]+" tags) ;; No boolean logic, just a list (setq tags (replace-match ":" t t tags)))) + (if (string-match "\\`[\t ]*\\'" tags) (setq tags "") (unless (string-match ":$" tags) (setq tags (concat tags ":"))) @@ -11650,7 +11785,7 @@ With prefix ARG, realign all tags in headings in the current buffer." org-tags-column (- (- org-tags-column) (length tags)))) rpl (concat (make-string (max 0 (- c1 c0)) ?\ ) tags))) - (replace-match rpl) + (replace-match rpl t t) (and (not (featurep 'xemacs)) c0 (tabify p0 (point))) tags) (error "Tags alignment failed"))))) @@ -12008,9 +12143,9 @@ used to insert the time stamp into the buffer to include the time." (timestr (format-time-string (if with-time "%Y-%m-%d %H:%M" "%Y-%m-%d") default-time)) (prompt (concat (if prompt (concat prompt " ") "") - (format "YYYY-MM-DD [%s]: " timestr))) + (format "Date and/or time (default [%s]): " timestr))) ans (org-ans0 "") org-ans1 org-ans2 (deltadays 0) - second minute hour day month year tl wday wday1) + second minute hour day month year tl wday wday1 pm) (cond (from-string (setq ans from-string)) @@ -12058,7 +12193,6 @@ used to insert the time stamp into the buffer to include the time." (progn (use-local-map map) (setq org-ans0 (read-string prompt "" nil nil)) -; (if (not (string-match "\\S-" org-ans0)) (setq org-ans0 nil)) ;; org-ans0: from prompt ;; org-ans1: from mouse click ;; org-ans2: from calendar motion @@ -12071,17 +12205,30 @@ used to insert the time stamp into the buffer to include the time." (if (string-match "^[ \t]*[-+][0-9]+[ \t]*$" org-ans0) (setq deltadays (string-to-number ans) ans "")) - (if (string-match - "^ *\\(\\([0-9]+\\)-\\)?\\([0-1]?[0-9]\\)-\\([0-3]?[0-9]\\)\\([^-0-9]\\|$\\)" ans) - (progn - (setq year (if (match-end 2) - (string-to-number (match-string 2 ans)) - (string-to-number (format-time-string "%Y"))) - month (string-to-number (match-string 3 ans)) - day (string-to-number (match-string 4 ans))) - (if (< year 100) (setq year (+ 2000 year))) - (setq ans (replace-match (format "%04d-%02d-%02d\\5" year month day) - t nil ans)))) + ;; Help matching ISO dates with single digit month ot day, like 2006-8-11. + (when (string-match + "^ *\\(\\([0-9]+\\)-\\)?\\([0-1]?[0-9]\\)-\\([0-3]?[0-9]\\)\\([^-0-9]\\|$\\)" ans) + (setq year (if (match-end 2) + (string-to-number (match-string 2 ans)) + (string-to-number (format-time-string "%Y"))) + month (string-to-number (match-string 3 ans)) + day (string-to-number (match-string 4 ans))) + (if (< year 100) (setq year (+ 2000 year))) + (setq ans (replace-match (format "%04d-%02d-%02d\\5" year month day) + t nil ans))) + ;; Help matching am/pm times, because `parse-time-string' does not do that. + ;; If there is a time with am/pm, and *no* time without it, we convert + ;; convert so that matching will be successful. + (when (and (not (string-match "[012]?[0-9]:[0-9][0-9]\\([ \t\n]\\|$\\)" ans)) + (string-match "\\([012]?[0-9]\\)\\(:\\([0-5][0-9]\\)\\)?\\(am\\|AM\\|pm\\|PM\\)\\>" ans)) + (setq hour (string-to-number (match-string 1 ans)) + minute (if (match-end 3) (string-to-number (match-string 3 ans)) 0) + pm (equal ?p (string-to-char (downcase (match-string 4 ans))))) + (if (and (= hour 12) (not pm)) + (setq hour 0) + (if (and pm (< hour 12)) (setq hour (+ 12 hour)))) + (setq ans (replace-match (format "%02d:%02d" hour minute) t t ans))) + (setq tl (parse-time-string ans) year (or (nth 5 tl) (string-to-number (format-time-string "%Y" ct))) month (or (nth 4 tl) (string-to-number (format-time-string "%m" ct))) @@ -12118,7 +12265,16 @@ Also, store the cursor date in variable org-ans2." (time (encode-time 0 0 0 (nth 1 date) (nth 0 date) (nth 2 date)))) (setq org-ans2 (format-time-string "%Y-%m-%d" time)))) (org-move-overlay org-date-ovl (1- (point)) (1+ (point)) (current-buffer)) - (select-window sw))) + (select-window sw) + ;; Update the prompt to show new default date + (save-excursion + (goto-char (point-min)) + (when (and (re-search-forward "\\[[-0-9]+\\]" nil t) + (get-text-property (match-end 0) 'field)) + (let ((inhibit-read-only t)) + (replace-match (concat "[" org-ans2 "]") t t) + (add-text-properties (point-min) (1+ (match-end 0)) + (text-properties-at (1+ (point-min))))))))) (defun org-calendar-select () "Return to `org-read-date' with the date currently selected. @@ -12981,6 +13137,7 @@ The following commands are available: (define-key org-agenda-mode-map "\C-m" 'org-agenda-switch-to) (define-key org-agenda-mode-map "\C-k" 'org-agenda-kill) (define-key org-agenda-mode-map "\C-c$" 'org-agenda-archive) +(define-key org-agenda-mode-map "\C-c\C-x\C-s" 'org-agenda-archive) (define-key org-agenda-mode-map "$" 'org-agenda-archive) (define-key org-agenda-mode-map "\C-c\C-o" 'org-agenda-open-link) (define-key org-agenda-mode-map " " 'org-agenda-show) @@ -13631,7 +13788,7 @@ Optional argument FILE means, use this file instead of the current." (when org-agenda-skip-archived-trees (goto-char (point-min)) (while (re-search-forward rea nil t) - (if (org-on-heading-p) + (if (org-on-heading-p t) (add-text-properties (point-at-bol) (org-end-of-subtree t) pa)))) (goto-char (point-min)) (setq re (concat "^\\*+ +" org-comment-string "\\>")) @@ -14443,6 +14600,7 @@ the documentation of `org-diary'." 'help-echo (format "mouse-2 or RET jump to org file %s" (abbreviate-file-name buffer-file-name)))) + ;; FIXME: get rid of the \n at some point but watch out (regexp (concat "[\n\r]\\*+ *\\(" (if org-select-this-todo-keyword (concat "\\<\\(" org-select-this-todo-keyword @@ -14465,6 +14623,7 @@ the documentation of `org-diary'." (goto-char beg) (or org-agenda-todo-list-sublevels (org-end-of-subtree 'invisible)) (throw :skip nil))) + (goto-char beg) (org-agenda-skip) (goto-char (match-beginning 1)) (setq marker (org-agenda-new-marker (1+ (match-beginning 0))) @@ -14883,7 +15042,7 @@ only the correctly processes TXT should be returned - this is used by 'time-of-day time-of-day 'dotime dotime)))) -(defvar org-agenda-sorting-strategy) +(defvar org-agenda-sorting-strategy) ;; FIXME: can be removed? (defvar org-agenda-sorting-strategy-selected nil) (defun org-agenda-add-time-grid-maybe (list ndays todayp) @@ -15663,10 +15822,12 @@ the tags of the current headline come last." (with-current-buffer buffer (widen) (goto-char pos) - (org-show-context 'agenda) + (save-excursion + (org-show-context 'agenda)) (save-excursion (and (outline-next-heading) (org-flag-heading nil))) ; show the next heading + (goto-char pos) (call-interactively 'org-set-tags) (end-of-line 1) (setq newhead (org-get-heading))) @@ -16770,7 +16931,7 @@ translations. There is currently no way for users to extend this.") (when (not (eq org-export-with-archived-trees t)) (goto-char (point-min)) (while (re-search-forward re-archive nil t) - (if (not (org-on-heading-p)) + (if (not (org-on-heading-p t)) (org-end-of-subtree t) (beginning-of-line 1) (delete-region @@ -17442,7 +17603,7 @@ org-mode's default settings, but still inferior to file-local settings." (coding-system-get coding-system 'mime-charset))) table-open type table-buffer table-orig-buffer - ind start-is-num starter + ind start-is-num starter didclose rpl path desc descp desc1 desc2 link ) (message "Exporting...") @@ -17792,10 +17953,12 @@ lang=\"%s\" xml:lang=\"%s\"> (unless (string-match "[^ \t]" line) ;; empty line. Pretend indentation is large. (setq ind (1+ (or (car local-list-indent) 1)))) + (setq didclose nil) (while (and in-local-list (or (and (= ind (car local-list-indent)) (not starter)) (< ind (car local-list-indent)))) + (setq didclose t) (org-close-li) (insert (if (car local-list-num) "\n" "")) (pop local-list-num) (pop local-list-indent) @@ -17804,7 +17967,7 @@ lang=\"%s\" xml:lang=\"%s\"> ((and starter (or (not in-local-list) (> ind (car local-list-indent)))) - ;; Start new (level of ) list + ;; Start new (level of) list (org-close-par-maybe) (insert (if start-is-num "
    \n
  1. \n" "
      \n
    • \n")) (push start-is-num local-list-num) @@ -17813,7 +17976,10 @@ lang=\"%s\" xml:lang=\"%s\"> (starter ;; continue current list (org-close-li) - (insert "
    • \n"))) + (insert "
    • \n")) + (didclose + ;; we did close a list, normal text follows: need

      + (org-open-par))) (if (string-match "^[ \t]*\\[\\([X ]\\)\\]" line) (setq line (replace-match @@ -18206,10 +18372,6 @@ stacked delimiters is N. Escaping delimiters is not possible." "Close

    • if necessary." (org-close-par-maybe) (insert "
    • \n")) -; (when (save-excursion -; (re-search-backward "" nil t)) -; (if (member (match-string 0) '("
    " "
" "
  • ")) -; (insert "
  • ")))) (defun org-html-level-start (level title umax with-toc head-count) "Insert a new level in HTML export. @@ -18258,7 +18420,7 @@ When TITLE is nil, just close all open levels." (defun org-html-level-close (&rest args) "Terminate one level in HTML export." (org-close-li) - (insert "")) + (insert "\n")) ;;; iCalendar export @@ -18535,13 +18697,6 @@ The XOXO buffer is named *xoxo-*" ;;;; Key bindings -;; - Bindings in Org-mode map are currently -;; 0123456789abcdefghijklmnopqrstuvwxyz!?@#$%^&-+*/=()_{}[]:;"|,.<>~`'\t the alphabet -;; abcd fgh j lmnopqrstuvwxyz!? #$ ^ -+*/= [] ; |,.<>~ '\t necessary bindings -;; e (?) useful from outline-mode -;; i k @ expendable from outline-mode -;; 0123456789 % & ()_{} " ` free - ;; Make `C-c C-x' a prefix key (define-key org-mode-map "\C-c\C-x" (make-sparse-keymap)) @@ -18763,6 +18918,12 @@ because, in this case the deletion might narrow the column." (put 'org-delete-char 'delete-selection 'supersede) (put 'org-delete-backward-char 'delete-selection 'supersede) +;; Make `flyspell-mode' delay after some commands +(put 'org-self-insert-command 'flyspell-delayed t) +(put 'orgtbl-self-insert-command 'flyspell-delayed t) +(put 'org-delete-char 'flyspell-delayed t) +(put 'org-delete-backward-char 'flyspell-delayed t) + ;; How to do this: Measure non-white length of current string ;; If equal to column width, we should realign. @@ -19193,6 +19354,7 @@ See the individual commands for more information." ["Priority Up" org-shiftup t] ["Priority Down" org-shiftdown t] "--" + ;; FIXME: why is this still here???? ; ["Insert Checkbox" org-insert-todo-heading (org-in-item-p)] ; ["Toggle Checkbox" org-ctrl-c-ctrl-c (org-at-item-checkbox-p)] ; ["Insert [n/m] cookie" (progn (insert "[/]") (org-update-checkbox-count)) @@ -19377,7 +19539,7 @@ and :keyword." (p (point)) clist o) ;; First the large context (cond - ((org-on-heading-p) + ((org-on-heading-p t) (push (list :headline (point-at-bol) (point-at-eol)) clist) (when (progn (beginning-of-line 1) @@ -19558,7 +19720,22 @@ not an indirect buffer" ;;; Paragraph filling stuff. ;; We want this to be just right, so use the full arsenal. -;; FIXME: configure filladapt for XEmacs + +(defun org-indent-line-function () + "Indent line like previous, but further if previous was headline or item." + (interactive) + (let ((column (save-excursion + (beginning-of-line) + (if (looking-at "#") 0 + (skip-chars-backward "\n \t") + (beginning-of-line) + (if (or (looking-at "\\*+[ \t]+") + (looking-at "[ \t]*\\([-+*][ \t]+\\|[0-9]+[.)][ \t]+\\)")) + (progn (goto-char (match-end 0)) (current-column)) + (current-indentation)))))) + (if (<= (current-column) (current-indentation)) + (indent-line-to column) + (save-excursion (indent-line-to column))))) (defun org-set-autofill-regexps () (interactive) @@ -19615,6 +19792,7 @@ work correctly." (t nil))) +;; FIXME: these 2 functions are not in the right place. (defun org-image-file-name-regexp () "Return regexp matching the file names of images." (if (fboundp 'image-file-name-regexp) @@ -19833,6 +20011,179 @@ Show the heading too, if it is currently invisible." ;;;; Experimental code +(defun org-table-formula-to-user (s) + "Convert a formula from internal to user representation." + (if (eq org-table-use-standard-references t) + (org-table-convert-refs-to-an s) + s)) + +(defun org-table-formula-from-user (s) + "Convert a formula from user to internal representation." + (if org-table-use-standard-references + (org-table-convert-refs-to-rc s) + s)) + +(defun org-table-convert-refs-to-rc (s) + "Convert spreadsheet references from AB7 to @7$28. +Works for single references, but also for entire formulas and even the +full TBLFM line." + (let ((start 0)) + (while (string-match "\\<\\([a-zA-Z]+\\)\\([0-9]+\\>\\|&\\)\\|\\(;[^\r\n:]+\\)" s start) + (if (match-end 3) + ;; format match, just advance + (setq start (match-end 0)) + (setq start (match-beginning 0) + s (replace-match + (if (equal (match-string 2 s) "&") + (format "$%d" (org-letters-to-number (match-string 1 s))) + (format "@%d$%d" + (string-to-number (match-string 2 s)) + (org-letters-to-number (match-string 1 s)))) + t t s)))) + s)) + +(defun org-table-convert-refs-to-an (s) + "Convert spreadsheet references from to @7$28 to AB7. +Works for single references, but also for entire formulas and even the +full TBLFM line." + (while (string-match "@\\([0-9]+\\)$\\([0-9]+\\)" s) + (setq s (replace-match + (format "%s%d" + (org-number-to-letters + (string-to-number (match-string 2 s))) + (string-to-number (match-string 1 s))) + t t s))) + (while (string-match "\\(^\\|[^0-9a-zA-Z]\\)\\$\\([0-9]+\\)" s) + (setq s (replace-match (concat "\\1" + (org-number-to-letters + (string-to-number (match-string 2 s))) "&") + t nil s))) + s) + +(defun org-letters-to-number (s) + "Convert a base 26 number represented by letters into an integer. +For example: AB -> 28." + (let ((n 0)) + (setq s (upcase s)) + (while (> (length s) 0) + (setq n (+ (* n 26) (string-to-char s) (- ?A) 1) + s (substring s 1))) + n)) + +(defun org-number-to-letters (n) + "Convert an integer into a base 26 number represented by letters. +For example: 28 -> AB." + (let ((s "")) + (while (> n 0) + (setq s (concat (char-to-string (+ (mod (1- n) 26) ?A)) s) + n (/ (1- n) 26))) + s)) + +(defun org-table-fedit-convert-buffer (function) + "Convert all references in this buffer, using FUNTION." + (let ((line (org-current-line))) + (goto-char (point-min)) + (while (not (eobp)) + (insert (funcall function (buffer-substring (point) (point-at-eol)))) + (delete-region (point) (point-at-eol)) + (or (eobp) (forward-char 1))) + (goto-line line))) + +(defvar org-table-buffer-is-an nil) + +(defun org-table-fedit-toggle-ref-type () + "Convert all references in the buffer from B3 to @3$2 and back." + (interactive) + (org-set-local 'org-table-buffer-is-an (not org-table-buffer-is-an)) + (org-table-fedit-convert-buffer + (if org-table-buffer-is-an + 'org-table-convert-refs-to-an 'org-table-convert-refs-to-rc)) + (message "Reference type switched to %s" + (if org-table-buffer-is-an "A1 etc" "@row$column"))) + +(defun org-table-fedit-ref-up () + "Shift the reference at point one row/hline up." + (interactive) + (org-table-fedit-shift-reference 'up)) +(defun org-table-fedit-ref-down () + "Shift the reference at point one row/hline down." + (interactive) + (org-table-fedit-shift-reference 'down)) +(defun org-table-fedit-ref-left () + "Shift the reference at point one field to the left." + (interactive) + (org-table-fedit-shift-reference 'left)) +(defun org-table-fedit-ref-right () + "Shift the reference at point one field to the right." + (interactive) + (org-table-fedit-shift-reference 'right)) + +(defun org-table-fedit-shift-reference (dir) + (cond + ((org-at-regexp-p "\\(\\<[a-zA-Z]\\)&") + (if (memq dir '(left right)) + (org-rematch-and-replace 1 (eq dir 'left)) + (error "Cannot shift reference in this direction"))) + ((org-at-regexp-p "\\(\\<[a-zA-Z]\\{1,2\\}\\)\\([0-9]+\\)") + ;; A B3-like reference + (if (memq dir '(up down)) + (org-rematch-and-replace 2 (eq dir 'up)) + (org-rematch-and-replace 1 (eq dir 'left)))) + ((org-at-regexp-p + "\\(@\\|\\.\\.\\)\\([-+]?\\(I+\\>\\|[0-9]+\\)\\)\\(\\$\\([-+]?[0-9]+\\)\\)?") + ;; An internal reference + (if (memq dir '(up down)) + (org-rematch-and-replace 2 (eq dir 'up) (match-end 3)) + (org-rematch-and-replace 5 (eq dir 'left)))))) + +(defun org-rematch-and-replace (n &optional decr hline) + "Re-match the group N, and replace it with the shifted refrence." + (or (match-end n) (error "Cannot shift reference in this direction")) + (goto-char (match-beginning n)) + (and (looking-at (regexp-quote (match-string n))) + (replace-match (org-shift-refpart (match-string 0) decr hline) + t t))) + +(defun org-shift-refpart (ref &optional decr hline) + "Shift a refrence part REF. +If DECR is set, decrease the references row/column, else increase. +If HLINE is set, this may be a hline reference, it certainly is not +a translation reference." + (save-match-data + (let* ((sign (string-match "^[-+]" ref)) n) + + (if sign (setq sign (substring ref 0 1) ref (substring ref 1))) + (cond + ((and hline (string-match "^I+" ref)) + (setq n (string-to-number (concat sign (number-to-string (length ref))))) + (setq n (+ n (if decr -1 1))) + (if (= n 0) (setq n (+ n (if decr -1 1)))) + (if sign + (setq sign (if (< n 0) "-" "+") n (abs n)) + (setq n (max 1 n))) + (concat sign (make-string n ?I))) + + ((string-match "^[0-9]+" ref) + (setq n (string-to-number (concat sign ref))) + (setq n (+ n (if decr -1 1))) + (if sign + (concat (if (< n 0) "-" "+") (number-to-string (abs n))) + (number-to-string (max 1 n)))) + + ((string-match "^[a-zA-Z]+" ref) + (org-number-to-letters + (max 1 (+ (org-letters-to-number ref) (if decr -1 1))))) + + (t (error "Cannot shift reference")))))) + +(defun org-table-fedit-toggle-coordinates () + "Toggle the display of coordinates in the refrenced table." + (interactive) + (let ((pos (marker-position org-pos))) + (with-current-buffer (marker-buffer org-pos) + (save-excursion + (goto-char pos) + (org-table-toggle-coordinate-overlays))))) ;;;; Finish up diff --git a/org.pdf b/org.pdf index e402b157c..ea47878cf 100644 Binary files a/org.pdf and b/org.pdf differ diff --git a/org.texi b/org.texi index 4b484f254..1f7d44de6 100644 --- a/org.texi +++ b/org.texi @@ -3,8 +3,8 @@ @setfilename ../info/org @settitle Org Mode Manual -@set VERSION 4.67 -@set DATE February 2007 +@set VERSION 4.68 +@set DATE March 2007 @dircategory Emacs @direntry @@ -162,7 +162,7 @@ TODO items * TODO basics:: Marking and displaying TODO entries * TODO extensions:: Workflow and assignments * Priorities:: Some things are more important than others -* Breaking down tasks:: Splitting a task into managable pieces +* Breaking down tasks:: Splitting a task into manageable pieces * Checkboxes:: Tick-off lists Extended use of TODO keywords @@ -243,7 +243,7 @@ Exporting HTML export -* Export commands:: How to invode HTML export +* Export commands:: How to invoke HTML export * Quoting HTML tags:: Using direct HTML in Org-mode * Links:: How hyperlinks get transferred to HTML * Images:: To inline or not to inline? @@ -370,7 +370,7 @@ example as: Org-mode's automatic, context sensitive table editor with spreadsheet capabilities can be integrated into any major mode by activating the minor Orgtbl-mode. Using a translation step, it can be used to maintain -tables in arbitray file types, for example in LaTeX. +tables in arbitrary file types, for example in LaTeX. @cindex FAQ There is a website for Org-mode which provides links to the newest @@ -1319,7 +1319,7 @@ value. @noindent Fields that are wider become clipped and end in the string @samp{=>}. Note that the full text is still in the buffer, it is only invisible. -To see the full text, hold the mouse over the field - a tooltip window +To see the full text, hold the mouse over the field - a tool-tip window will show the full content. To edit such a field, use the command @kbd{C-c `} (that is @kbd{C-c} followed by the backquote). This will open a new window with the full field. Edit it and finish with @kbd{C-c @@ -1355,7 +1355,7 @@ example in mail mode, use Furthermore, with some special setup, it is possible to maintain tables in arbitrary syntax with Orgtbl-mode. For example, it is possible to construct LaTeX tables with the underlying ease and power of -Orgtbl-mode, including spreadsheet capabulities. For details, see +Orgtbl-mode, including spreadsheet capabilities. For details, see @ref{Tables in arbitrary syntax}. @node The spreadsheet, , orgtbl-mode, Tables @@ -1366,7 +1366,12 @@ Orgtbl-mode, including spreadsheet capabulities. For details, see The table editor makes use of the Emacs @file{calc} package to implement spreadsheet-like capabilities. It can also evaluate Emacs Lisp forms to -derive fields from other fields. +derive fields from other fields. While fully featured, Org-mode's +implementation is not identical to other spreadsheets. For example, +Org-mode knows the concept of a @emph{column formula} that will be +applied to all non-header fields in a column without having to copy the +formula to each relevant field. + @menu * References:: How to refer to another field or range * Formula syntax for Calc:: Using Calc to compute stuff @@ -1386,17 +1391,26 @@ To compute fields in the table from other fields, formulas must reference other fields or ranges. In Org-mode, fields can be referenced by name, by absolute coordinates, and by relative coordinates. To find out what the coordinates of a field are, press @kbd{C-c ?} in that -field. +field, or press @kbd{C-c @}} to toggle the display of a grid. @subsubheading Field references @cindex field references @cindex references, to fields -Formulas can reference the value of another field with the operator +Formulas can reference the value of another field in two ways. Like in +any other spreadsheet, you may reference fields with a letter/number +combination like @code{B3}, meaning the 2nd field in the 3rd row. +@c Such references are always fixed to that field, they don't change +@c when you copy and paste a formula to a different field. So +@c Org-mode's @code{B3} behaves like @code{$B$3} in other spreadsheets. + +@noindent +Org-mode also uses another, more general operator that looks like this: @example @@row$column @end example +@noindent Column references can be absolute like @samp{1}, @samp{2},...@samp{N}, or relative to the current column like @samp{+1} or @samp{-2}. @@ -1416,18 +1430,20 @@ directly at the hline is used. either the column or the row part of the reference, the current row/column is implied. -Org-mode's references with @emph{positive} numbers correspond to fixed -references in other spreadsheet programs. For example, @code{@@3$28} -corresponds to @code{$AB$3}. Org-mode's references with @emph{negative} -numbers behave similar to non-fixed references in other spreadsheet -programs, because when the same formula is used in several fields, -different fields are referenced each time. +Org-mode's references with @emph{unsigned} numbers are fixed references +in the sense that if you use the same reference in the formula for two +different fields, the same field will be referenced each time. +Org-mode's references with @emph{signed} numbers are floating +references because the same reference operator can reference different +fields depending on the field being calculated by the formula. Here are a few examples: @example @@2$3 @r{2nd row, 3rd column} +C2 @r{same as previous} $5 @r{column 5 in the current row} +E& @r{same as previous} @@2 @r{current column, row 2} @@-1$-3 @r{the field one row up, three columns to the left} @@-I$2 @r{field just under hline above current row, column 2} @@ -1448,6 +1464,7 @@ format at least for the first field (i.e the reference must start with $1..$3 @r{First three fields in the current row.} $P..$Q @r{Range, using column names (see under Advanced)} @@2$1..@@4$3 @r{6 fields between these two fields.} +A2..C4 @r{Same as above.} @@-1$-2..@@-1 @r{3 numbers from the column to the left, 2 up to current row} @end example @@ -1465,12 +1482,16 @@ see the @samp{E} mode switch below). If there are no non-empty fields, @samp{$name} is interpreted as the name of a column, parameter or constant. Constants are defined globally through the variable -@code{org-table-formula-constants}. If you have the -@file{constants.el} package, it will also be used to resolve -constants, including natural constants like @samp{$h} for Planck's -constant, and units like @samp{$km} for kilometers. Column names and -parameters can be specified in special table lines. These are -described below, see @ref{Advanced features}. +@code{org-table-formula-constants}. If you have the @file{constants.el} +package, it will also be used to resolve constants, including natural +constants like @samp{$h} for Planck's constant, and units like +@samp{$km} for kilometers@footnote{@file{Constant.el} can supply the +values of constants in two different unit systems, @code{SI} and +@code{cgs}. Which one is used depends on the value of the variable +@code{constants-unit-system}. You can use the @code{#+STARTUP} options +@code{constSI} and @code{constcgs} to set this value for the current +buffer.}. Column names and parameters can be specified in special table +lines. These are described below, see @ref{Advanced features}. @node Formula syntax for Calc, Formula syntax for Lisp, References, The spreadsheet @subsection Formula syntax for Calc @@ -1517,7 +1538,7 @@ reformat the final result. A few examples: $1+$2 @r{Sum of first and second field} $1+$2;%.2f @r{Same, format result to two decimals} exp($2)+exp($1) @r{Math functions can be used} -$;%.1f @r{Reformat current cell to 1 decimal} +$0;%.1f @r{Reformat current cell to 1 decimal} ($3-32)*5/9 @r{Degrees F -> C conversion} $c/$1/$cm @r{Hz -> cm conversion, using @file{constants.el}} tan($1);Dp3s1 @r{Compute in degrees, precision 3, display SCI 1} @@ -1527,21 +1548,28 @@ vmean($2..$7);EN @r{Same, but treat empty fields as 0} taylor($3,x=7,2) @r{taylor series of $3, at x=7, second degree} @end example +Calc also contains a complete set of logical operations. For example + +@example +if($1<20,teen,string("")) @r{``teen'' if age $1 less than 20, else empty} +@end example + @node Formula syntax for Lisp, Field formulas, Formula syntax for Calc, The spreadsheet @subsection Emacs Lisp forms as formulas @cindex Lisp forms, as table formulas It is also possible to write a formula in Emacs Lisp; this can be useful -for string manipulation and control structures. If a formula starts -with a single quote followed by an opening parenthesis, then it is -evaluated as a lisp form. The evaluation should return either a string -or a number. Just as with @file{calc} formulas, you can specify modes -and a printf format after a semicolon. A reference will be replaced -with a string (in double quotes) containing the field. If you provide -the @samp{N} mode switch, all referenced elements will be numbers. -Ranges are inserted as space-separated fields, so you can embed them in -list or vector syntax. A few examples, note how the @samp{N} mode is -used when we do computations in lisp. +for string manipulation and control structures, if the Calc's +functionality is not enough. If a formula starts with a single quote +followed by an opening parenthesis, then it is evaluated as a lisp form. +The evaluation should return either a string or a number. Just as with +@file{calc} formulas, you can specify modes and a printf format after a +semicolon. A reference will be replaced with a string (in double +quotes) containing the field. If you provide the @samp{N} mode switch, +all referenced elements will be numbers. Ranges are inserted as +space-separated fields, so you can embed them in list or vector syntax. +A few examples, note how the @samp{N} mode is used when we do +computations in lisp. @example @r{Swap the first two characters of the content of column 1} @@ -1566,12 +1594,11 @@ evaluated, and the current field replaced with the result. Formulas are stored in a special line starting with @samp{#+TBLFM:} directly below the table. If you typed the equation in the 4th field of the 3rd data line in the table, the formula will look like -@samp{@@3$2=$1+$2}. When inserting/deleting/swapping column and rows +@samp{@@3$4=$1+$2}. When inserting/deleting/swapping column and rows with the appropriate commands, @i{absolute references} (but not relative -ones) in stored formulas are modified in order to -still reference the same field. Of cause this is not true if you edit -the table structure with normal editing commands - then you must go and -fix equations yourself. +ones) in stored formulas are modified in order to still reference the +same field. Of cause this is not true if you edit the table structure +with normal editing commands - then you must fix the equations yourself. Instead of typing an equation into the field, you may also use the following command @@ -1592,7 +1619,9 @@ it to the current field and stores it. Often in a table, the same formula should be used for all fields in a particular column. Instead of having to copy the formula to all fields in that column, org-mode allows to assign a single formula to an entire -column. +column. If the table contains horizontal separator hlines, everything +before the first such line is considered part of the table @emph{header} +and will not be modified by column formulas. To assign a formula to a column, type it directly into any field in the column, preceded by an equal sign, like @samp{=$1+$2}. When you press @@ -1625,7 +1654,11 @@ will apply it to that many consecutive fields in the current column. You can edit individual formulas in the minibuffer or directly in the field. Org-mode can also prepare a special buffer with all active -formulas of a table. +formulas of a table. When offering a formula for editing, Org-mode +converts references to the standard format (like @code{B3} or @code{D&}) +if possible. If you prefer to only work with the internal format (like +@code{@@3$2} or @code{$4}), configure the variable +@code{org-table-use-standard-references}. @table @kbd @kindex C-c = @@ -1644,21 +1677,36 @@ minibuffer is that you can use the command @kbd{C-c ?}. @item C-c ? While editing a formula in a table field, highlight the field(s) referenced by the reference at the cursor position in the formula. +@kindex C-c @} +@item C-c @} +Toggle the display of row and column numbers for a table, using +overlays. These are updated each time the table is aligned, you can +force it with @kbd{C-c C-c}. +@kindex C-c @{ +@item C-c @{ +Toggle the formula debugger on and off. See below. @kindex C-c ' @item C-c ' Edit all formulas for the current table in a special buffer, where the -formulas will be displayed one per line. +formulas will be displayed one per line. If the current field has an +active formula, the cursor in the formula editor will mark it. While inside the special buffer, Org-mode will automatically highlight any field or range reference at the cursor position. You may edit, remove and add formulas, and use the following commands: @table @kbd @kindex C-c C-c +@kindex C-x C-s @item C-c C-c -Exit the buffer and store the modified formulas. With @kbd{C-u} prefix, -also apply the new formulas to the entire table. +@itemx C-x C-s +Exit the formula editor and store the modified formulas. With @kbd{C-u} +prefix, also apply the new formulas to the entire table. @kindex C-c C-q @item C-c C-q -Exit the buffer without installing changes. +Exit the formula editor without installing changes. +@kindex C-c C-r +@item C-c C-r +Toggle all references in the formula editor between standard (like +@code{B3}) and internal (like @code{@@3$2}). @kindex @key{TAB} @item @key{TAB} Pretty-print or indent lisp formula at point. When in a line containing @@ -1670,23 +1718,25 @@ formula, @key{TAB} re-indents just like in Emacs-lisp-mode. Complete Lisp symbols, just like in Emacs-lisp-mode. @kindex S-@key{up} @kindex S-@key{down} -@item S-@key{up}/@key{down} -Move the reference line in the Org-mode buffer up and down. This is -important for highlighting the references of column formulas for -different rows. +@kindex S-@key{left} +@kindex S-@key{right} +@item S-@key{up}/@key{down}/@key{left}/@key{right} +Shift the reference at point. For example, if the reference is +@code{B3} and you press @kbd{S-@key{right}}, it will become @code{C3}. +This also works for relative references, and for hline references. +@kindex M-S-@key{up} +@kindex M-S-@key{down} +@item M-S-@key{up}/@key{down} +Move the test line for column formulas in the Org-mode buffer up and +down. @kindex M-@key{up} @kindex M-@key{down} @item M-@key{up}/@key{down} Scroll the window displaying the table. -@end table @kindex C-c @} @item C-c @} -Toggle the display of row and column numbers for a table, using -overlays. These are uptated each time the table is aligned, you can -force it with @kbd{C-c C-c}. -@kindex C-c @{ -@item C-c @{ -Toggle the formula debugger on and off. See below. +Turn the coordinate grid in the table on and off. +@end table @end table Making a table field blank does not remove the formula associated with @@ -1707,8 +1757,8 @@ When the evaluation of a formula leads to an error, the field content becomes the string @samp{#ERROR}. If you would like see what is going on during variable substitution and calculation in order to find a bug, turn on formula debugging in the @code{Tbl} menu and repeat the -calculation, for example by pressing @kbd{C-c = @key{RET}} in a field. -Detailed information will be displayed. +calculation, for example by pressing @kbd{C-u C-u C-c = @key{RET}} in a +field. Detailed information will be displayed. @node Updating the table, Advanced features, Editing and debugging formulas, The spreadsheet @subsection Updating the Table @@ -1742,7 +1792,6 @@ This may be necessary if some computed fields use the value of other fields that are computed @i{later} in the calculation sequence. @end table - @node Advanced features, , Updating the table, The spreadsheet @subsection Advanced features @@ -2407,7 +2456,7 @@ template has been expanded: @noindent If you change you mind about which template to use, call @code{org-remember} in the remember buffer. You may then select a new -template that will be filled with the previoous context information. +template that will be filled with the previous context information. @node Storing notes, , Remember templates, Remember @subsection Storing notes @@ -2466,7 +2515,7 @@ things you have to do. * TODO basics:: Marking and displaying TODO entries * TODO extensions:: Workflow and assignments * Priorities:: Some things are more important than others -* Breaking down tasks:: Splitting a task into managable pieces +* Breaking down tasks:: Splitting a task into manageable pieces * Checkboxes:: Tick-off lists @end menu @@ -2686,7 +2735,7 @@ Furthermore, these keys are also used by CUA-mode (@pxref{Conflicts}). @section Breaking tasks down into subtasks @cindex tasks, breaking down -It is often advisable to break down large tasks into smaller, managable +It is often advisable to break down large tasks into smaller, manageable subtasks. You can do this by creating an outline tree below a TODO item, with detailed subtasks on the tree@footnote{To keep subtasks out of the global TODO list, see the @@ -2907,8 +2956,8 @@ see the option @code{org-time-stamp-rounding-minutes}. @kindex C-c ! @item C-c ! -Like @kbd{C-c .}, but insert an inactive time stamp not triggering the -agenda. +Like @kbd{C-c .}, but insert an inactive time stamp that will not cause +an agenda entry. @kindex C-c < @item C-c < @@ -4772,7 +4821,7 @@ HTML formatting, in ways similar to John Grubers @emph{markdown} language, but with additional support for tables. @menu -* Export commands:: How to invode HTML export +* Export commands:: How to invoke HTML export * Quoting HTML tags:: Using direct HTML in Org-mode * Links:: How hyperlinks get transferred to HTML * Images:: To inline or not to inline? @@ -5611,6 +5660,14 @@ To turn on custom format overlays over time stamps (variables @example customtime @r{overlay custom time format} @end example +The following options influence the table spreadsheet (variable +@code{constants-unit-system}). +@cindex @code{constcgs}, STARTUP keyword +@cindex @code{constSI}, STARTUP keyword +@example +constcgs @r{@file{constants.el} should use the c-g-s unit system} +constSI @r{@file{constants.el} should use the SI unit system} +@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 fe4cea57f..a6ad811f1 100644 Binary files a/orgcard.pdf and b/orgcard.pdf differ diff --git a/orgcard.tex b/orgcard.tex index d44689ad4..1d7723cee 100644 --- a/orgcard.tex +++ b/orgcard.tex @@ -1,6 +1,7 @@ % Reference Card for Org Mode -\def\orgversionnumber{4.67} -\def\year{2007} +\def\orgversionnumber{4.68} +\def\versionyear{2007} % latest update +\def\year{2007} % latest copyright year % %**start of header \newcount\columnsperpage @@ -20,7 +21,7 @@ \columnsperpage=3 -% Copyright (c) 2004, 2005, 2006, 2007 Free Software Foundation +% Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc % GNU Emacs is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by @@ -61,14 +62,14 @@ % for their many good ideas. \def\shortcopyrightnotice{\vskip 1ex plus 2 fill - \centerline{\small \copyright\ 2004, 2005, 2006, 2007\ Free Software Foundation, Inc. + \centerline{\small \copyright\ \year\ Free Software Foundation, Inc. Permissions on back. v\orgversionnumber}} \def\copyrightnotice{ \vskip 1ex plus 100 fill\begingroup\small \centerline{Copyright \copyright\ \year\ Free Software Foundation, Inc.} -\centerline{v\orgversionnumber{} for Org-Mode \orgversionnumber{}, \year} -\centerline{Authors: Philip Rooke \& Carsten Dominik} +\centerline{v\orgversionnumber{} for Org-Mode \orgversionnumber{}, \versionyear} +\centerline{Author: Philip Rooke} \centerline{based on refcard design and format by Stephen Gildea} Permission is granted to make and distribute copies of @@ -377,34 +378,6 @@ Outside of tables, the same keys may have other functionality. \key{paste rectangular region}{C-c C-x C-y} \key{fill paragraph across selected cells}{C-c C-q} -{\bf Calculations} (in combination with Emacs \kbd{calc} package) - -\key{set and eval column formula}{C-c =} -\key{set and eval field formula}{C-u C-c =} -\key{edit formulas in separate buffer}{C-c '} -\key{re-apply all stored equations to current line}{C-c *} -\key{re-apply all stored equations to entire table}{C-u C-c *} -\key{iterate table to stability}{C-u C-u C-c *} - -%\kbd{TAB}, \kbd{RET} and \kbd{C-c C-c} trigger automatic recalculation -%in lines starting with: {\tt | \# |}. - -\key{rotate calculation mark through \# * ! \^ \_ \$}{C-\#} - -\key{show line, column, formula reference}{C-c ?} -\key{sum numbers in current column/rectangle}{C-c +} -\key{copy down with increment}{S-RET$^3$} - -Formulas typed in field are executed by \kbd{TAB}, -\kbd{RET} and \kbd{C-c C-c}. \kbd{=} introduces a column -formula, \kbd{:=} a named-field formula. - -\key{Example: Add Col1 and Col2}{=\$1+\$2} -\key{... with printf format specification}{=\$1+\$2;\%.2f} -\key{... with constants from constants.el}{=\$1/\$c/\$cm} -\metax{sum from 2nd to 3rd hline}{:=vsum(@II..@III)} -\key{apply current column formula}{=} - {\bf Miscellaneous} \key{to limit column width to \kbd{N} characters, use}{...| |...} @@ -412,6 +385,8 @@ formula, \kbd{:=} a named-field formula. \key{make current field fully visible}{C-u TAB} \metax{export as tab-separated file}{M-x org-table-export} \metax{import tab-separated file}{M-x org-table-import} +\key{sum numbers in current column/rectangle}{C-c +} +\key{copy down with increment}{S-RET$^3$} {\bf Tables created with the \kbd{table.el} package} @@ -419,6 +394,42 @@ formula, \kbd{:=} a named-field formula. \key{recognize existing table.el table}{C-c C-c} \key{convert table (Org-mode $\leftrightarrow$ table.el)}{C-c ~} +{\bf Spreadsheet} + +Formulas typed in field are executed by \kbd{TAB}, +\kbd{RET} and \kbd{C-c C-c}. \kbd{=} introduces a column +formula, \kbd{:=} a field formula. + +\key{Example: Add Col1 and Col2}{|=\$1+\$2 |} +\key{... with printf format specification}{|=\$1+\$2;\%.2f|} +\key{... with constants from constants.el}{|=\$1/\$c/\$cm |} +\metax{sum from 2nd to 3rd hline}{|:=vsum(@II..@III)|} +\key{apply current column formula}{| = |} + +\key{set and eval column formula}{C-c =} +\key{set and eval field formula}{C-u C-c =} +\key{re-apply all stored equations to current line}{C-c *} +\key{re-apply all stored equations to entire table}{C-u C-c *} +\key{iterate table to stability}{C-u C-u C-c *} +\key{rotate calculation mark through \# * ! \^ \_ \$}{C-\#} +\key{show line, column, formula reference}{C-c ?} +\key{toggle coordinate grid}{C-c \}} +\key{toggle formula debugger}{C-c \{} + +{\it Formula Editor} + +\key{edit formulas in separate buffer}{C-c '} +\key{exit and install new formulas}{C-c C-c} +\key{exit, install, and apply new formulas}{C-u C-c C-c} +\key{abort}{C-c C-q} +\key{toggle reference style}{C-c C-r} +\key{pretty-print Lisp formula}{TAB} +\key{complete Lisp symbol}{M-TAB} +\key{shift reference point}{S-cursor} +\key{shift test line for column references}{M-up/down} +\key{scroll the window showing the table}{M-S-up/down} +\key{toggle table coordinate grid}{C-c \}} + \section{Links} \key{globally store link to the current location}{C-c l$^1$} @@ -465,24 +476,24 @@ formula, \kbd{:=} a named-field formula. %\key{\kbd{vm://myself@some.where.org/folder\#id}}{\rm VM remote} -\section{Remember-mode Integration} +% \section{Remember-mode Integration} -See the manual for how to make remember.el use Org-mode links and -files. The note-finishing command \kbd{C-c C-c} will first prompt for -an org file. In the file, find a location with: +% See the manual for how to make remember.el use Org-mode links and +% files. The note-finishing command \kbd{C-c C-c} will first prompt for +% an org file. In the file, find a location with: -\key{rotate subtree visibility}{TAB} -\key{next heading}{DOWN} -\key{previous heading}{UP} +% \key{rotate subtree visibility}{TAB} +% \key{next heading}{DOWN} +% \key{previous heading}{UP} -Insert the note with one of the following: +% Insert the note with one of the following: -\key{as sublevel of heading at cursor}{RET} -\key{right here (cursor not on heading)}{RET} -\key{before current heading}{LEFT} -\key{after current heading}{RIGHT} -\key{shortcut to end of buffer (cursor at buf-start)}{RET} -\key{Abort}{q} +% \key{as sublevel of heading at cursor}{RET} +% \key{right here (cursor not on heading)}{RET} +% \key{before current heading}{LEFT} +% \key{after current heading}{RIGHT} +% \key{shortcut to end of buffer (cursor at buf-start)}{RET} +% \key{Abort}{q} \section{Completion}