diff options
| author | Carsten Dominik | 2005-01-14 10:47:42 +0000 |
|---|---|---|
| committer | Carsten Dominik | 2005-01-14 10:47:42 +0000 |
| commit | 791d856fac4b758075baac06b26f9be9d7cf8806 (patch) | |
| tree | a9d95a8f6a1ce1696480532f69cf2fa800e1fb0f | |
| parent | 880d0c354f8a9e3939ed8c472e041362b6b3491b (diff) | |
| download | emacs-791d856fac4b758075baac06b26f9be9d7cf8806.tar.gz emacs-791d856fac4b758075baac06b26f9be9d7cf8806.zip | |
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
* org.el (org-show-following-heading): New option.
(org-show-hierarchy-above): Use `org-show-following-heading'.
* org.el (orgtbl-optimized): New option
(orgtbl-mode): New command, a minor mode.
(orgtbl-mode-map): New variable.
(turn-on-orgtbl, orgtbl-mode, orgtbl-make-binding)
(orgtbl-error, orgtbl-self-insert-command)
(orgtbl-delete-backward-char, orgtbl-delete-char): New functions.
* org.el (org-mode): `org-table-may-need-update' is now a local
variable in each org-mode buffer.
* org.el (org-set-regexps-and-options): Renamed from
`org-set-regexps'. Added checking for STARTUP keyword.
(org-get-current-options): Added STARTUP options.
(org-table-insert-row): Mode mode intelligent about when
realignment is needed.
(org-self-insert-command, org-delete-backward-char,
org-delete-char): New commands.
(org-enable-table-editor): new default value `optimized'.
(org-table-blank-field): Support blanking regions if active.
| -rw-r--r-- | lisp/ChangeLog | 25 | ||||
| -rw-r--r-- | lisp/textmodes/org.el | 605 |
2 files changed, 582 insertions, 48 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a702dc3d89a..4cc298e29a1 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,28 @@ | |||
| 1 | 2005-01-14 Carsten Dominik <dominik@science.uva.nl> | ||
| 2 | |||
| 3 | * textmodes/org.el (org-show-following-heading): New option. | ||
| 4 | (org-show-hierarchy-above): Use `org-show-following-heading'. | ||
| 5 | |||
| 6 | * textmodes/org.el (orgtbl-optimized): New option | ||
| 7 | (orgtbl-mode): New command, a minor mode. | ||
| 8 | (orgtbl-mode-map): New variable. | ||
| 9 | (turn-on-orgtbl, orgtbl-mode, orgtbl-make-binding) | ||
| 10 | (orgtbl-error, orgtbl-self-insert-command) | ||
| 11 | (orgtbl-delete-backward-char, orgtbl-delete-char): New functions. | ||
| 12 | |||
| 13 | * textmodes/org.el (org-mode): `org-table-may-need-update' is now | ||
| 14 | a local variable in each org-mode buffer. | ||
| 15 | |||
| 16 | * textmodes/org.el (org-set-regexps-and-options): Renamed from | ||
| 17 | `org-set-regexps'. Added checking for STARTUP keyword. | ||
| 18 | (org-get-current-options): Added STARTUP options. | ||
| 19 | (org-table-insert-row): Mode mode intelligent about when | ||
| 20 | realignment is needed. | ||
| 21 | (org-self-insert-command, org-delete-backward-char, | ||
| 22 | org-delete-char): New commands. | ||
| 23 | (org-enable-table-editor): new default value `optimized'. | ||
| 24 | (org-table-blank-field): Support blanking regions if active. | ||
| 25 | |||
| 1 | 26 | ||
| 2 | 2005-01-14 Carsten Dominik <dominik@science.uva.nl> | 27 | 2005-01-14 Carsten Dominik <dominik@science.uva.nl> |
| 3 | 28 | ||
diff --git a/lisp/textmodes/org.el b/lisp/textmodes/org.el index fc1ffb329d9..2488ad7fcf2 100644 --- a/lisp/textmodes/org.el +++ b/lisp/textmodes/org.el | |||
| @@ -1,14 +1,14 @@ | |||
| 1 | ;; org.el --- Outline-based notes management and organizer | 1 | ;; org.el --- Outline-based notes management and organizer |
| 2 | 2 | ;; Carstens outline-mode for keeping track of everything. | |
| 3 | ;; Copyright (c) 2003, 2004 Free Software Foundation | 3 | ;; Copyright (c) 2004 Free Software Foundation |
| 4 | 4 | ;; | |
| 5 | ;; Author: Carsten Dominik <dominik at science dot uva dot nl> | 5 | ;; Author: Carsten Dominik <dominik at science dot uva dot nl> |
| 6 | ;; Keywords: outlines, hypermedia, calendar | 6 | ;; Keywords: outlines, hypermedia, calendar |
| 7 | ;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/ | 7 | ;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/ |
| 8 | ;; Version: 3.03 | 8 | ;; Version: 3.04 (internal CVS version is $Revision: 1.106 $) |
| 9 | 9 | ;; | |
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ;; | |
| 12 | ;; GNU Emacs is free software; you can redistribute it and/or modify | 12 | ;; GNU Emacs is free software; you can redistribute it and/or modify |
| 13 | ;; it under the terms of the GNU General Public License as published by | 13 | ;; it under the terms of the GNU General Public License as published by |
| 14 | ;; the Free Software Foundation; either version 2, or (at your option) | 14 | ;; the Free Software Foundation; either version 2, or (at your option) |
| @@ -23,9 +23,7 @@ | |||
| 23 | ;; along with GNU Emacs; see the file COPYING. If not, write to the | 23 | ;; along with GNU Emacs; see the file COPYING. If not, write to the |
| 24 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 24 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 25 | ;; Boston, MA 02111-1307, USA. | 25 | ;; Boston, MA 02111-1307, USA. |
| 26 | |||
| 27 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 26 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 28 | ;; Carsten's outline-mode for keeping track of everything. | ||
| 29 | ;; | 27 | ;; |
| 30 | ;;; Commentary: | 28 | ;;; Commentary: |
| 31 | ;; | 29 | ;; |
| @@ -59,6 +57,8 @@ | |||
| 59 | ;; (autoload 'org-diary "org" "Diary entries from Org mode") | 57 | ;; (autoload 'org-diary "org" "Diary entries from Org mode") |
| 60 | ;; (autoload 'org-agenda "org" "Multi-file agenda from Org mode" t) | 58 | ;; (autoload 'org-agenda "org" "Multi-file agenda from Org mode" t) |
| 61 | ;; (autoload 'org-store-link "org" "Store a link to the current location" t) | 59 | ;; (autoload 'org-store-link "org" "Store a link to the current location" t) |
| 60 | ;; (autoload 'orgtbl-mode "org" "Org tables as a minor mode" t) | ||
| 61 | ;; (autoload 'turn-on-orgtbl "org" "Org tables as a minor mode") | ||
| 62 | ;; (add-to-list 'auto-mode-alist '("\\.org$" . org-mode)) | 62 | ;; (add-to-list 'auto-mode-alist '("\\.org$" . org-mode)) |
| 63 | ;; (define-key global-map "\C-cl" 'org-store-link) | 63 | ;; (define-key global-map "\C-cl" 'org-store-link) |
| 64 | ;; (define-key global-map "\C-ca" 'org-agenda) | 64 | ;; (define-key global-map "\C-ca" 'org-agenda) |
| @@ -79,9 +79,18 @@ | |||
| 79 | ;; | 79 | ;; |
| 80 | ;; Changes: | 80 | ;; Changes: |
| 81 | ;; ------- | 81 | ;; ------- |
| 82 | ;; Version 3.04 | ||
| 83 | ;; - Table editor optimized to need fewer realignments, and to keep | ||
| 84 | ;; table shape when typing in fields. | ||
| 85 | ;; - A new minor mode, orgtbl-mode, introduces the Org-mode table editor | ||
| 86 | ;; into arbitrary major modes. | ||
| 87 | ;; - Fixed bug with realignment in XEmacs. | ||
| 88 | ;; - Startup options can be set with special #+STARTUP line. | ||
| 89 | ;; - Heading following a match in org-occur can be suppressed. | ||
| 90 | ;; | ||
| 82 | ;; Version 3.03 | 91 | ;; Version 3.03 |
| 83 | ;; - Copyright transfer to the FSF. | 92 | ;; - Copyright transfer to the FSF. |
| 84 | ;; - Effect of C-u and C-u C-u in org-timeline interchanged. | 93 | ;; - Effect of C-u and C-u C-u in org-timeline swapped. |
| 85 | ;; - Timeline now always contains today, and `.' jumps to it. | 94 | ;; - Timeline now always contains today, and `.' jumps to it. |
| 86 | ;; - Table editor: | 95 | ;; - Table editor: |
| 87 | ;; - cut and paste of regtangular regions in tables | 96 | ;; - cut and paste of regtangular regions in tables |
| @@ -204,7 +213,7 @@ | |||
| 204 | 213 | ||
| 205 | ;;; Customization variables | 214 | ;;; Customization variables |
| 206 | 215 | ||
| 207 | (defvar org-version "3.03" | 216 | (defvar org-version "3.04" |
| 208 | "The version number of the file org.el.") | 217 | "The version number of the file org.el.") |
| 209 | (defun org-version (arg) | 218 | (defun org-version (arg) |
| 210 | (interactive "P") | 219 | (interactive "P") |
| @@ -402,11 +411,11 @@ lisp variable `state'." | |||
| 402 | "Matches the SCHEDULED keyword together with a time stamp.") | 411 | "Matches the SCHEDULED keyword together with a time stamp.") |
| 403 | (make-variable-buffer-local 'org-scheduled-time-regexp) | 412 | (make-variable-buffer-local 'org-scheduled-time-regexp) |
| 404 | 413 | ||
| 405 | (defun org-set-regexps () | 414 | (defun org-set-regexps-and-options () |
| 406 | "Precompute regular expressions for current buffer." | 415 | "Precompute regular expressions for current buffer." |
| 407 | (when (eq major-mode 'org-mode) | 416 | (when (eq major-mode 'org-mode) |
| 408 | (let ((re (org-make-options-regexp | 417 | (let ((re (org-make-options-regexp |
| 409 | '("CATEGORY" "SEQ_TODO" "PRI_TODO" "TYP_TODO"))) | 418 | '("CATEGORY" "SEQ_TODO" "PRI_TODO" "TYP_TODO" "STARTUP"))) |
| 410 | (splitre "[ \t]+") | 419 | (splitre "[ \t]+") |
| 411 | kwds int key value cat) | 420 | kwds int key value cat) |
| 412 | (save-restriction | 421 | (save-restriction |
| @@ -426,7 +435,17 @@ lisp variable `state'." | |||
| 426 | kwds (append kwds (org-split-string value splitre)))) | 435 | kwds (append kwds (org-split-string value splitre)))) |
| 427 | ((equal key "TYP_TODO") | 436 | ((equal key "TYP_TODO") |
| 428 | (setq int 'type | 437 | (setq int 'type |
| 429 | kwds (append kwds (org-split-string value splitre))))) | 438 | kwds (append kwds (org-split-string value splitre)))) |
| 439 | ((equal key "STARTUP") | ||
| 440 | (let ((opts (org-split-string value splitre)) | ||
| 441 | (set '(("fold" org-startup-folded t) | ||
| 442 | ("nofold" org-startup-folded nil) | ||
| 443 | ("dlcheck" org-startup-with-deadline-check t) | ||
| 444 | ("nodlcheck" org-startup-with-deadline-check nil))) | ||
| 445 | l var val) | ||
| 446 | (while (setq l (assoc (pop opts) set)) | ||
| 447 | (setq var (nth 1 l) val (nth 2 l)) | ||
| 448 | (set (make-local-variable var) val))))) | ||
| 430 | ))) | 449 | ))) |
| 431 | (and cat (set (make-local-variable 'org-category) cat)) | 450 | (and cat (set (make-local-variable 'org-category) cat)) |
| 432 | (and kwds (set (make-local-variable 'org-todo-keywords) kwds)) | 451 | (and kwds (set (make-local-variable 'org-todo-keywords) kwds)) |
| @@ -465,8 +484,6 @@ lisp variable `state'." | |||
| 465 | (concat "\\<" org-scheduled-string " *<\\([^>]+\\)>")) | 484 | (concat "\\<" org-scheduled-string " *<\\([^>]+\\)>")) |
| 466 | (org-set-font-lock-defaults))) | 485 | (org-set-font-lock-defaults))) |
| 467 | 486 | ||
| 468 | ;(add-hook 'hack-local-variables-hook 'org-set-regexps) | ||
| 469 | |||
| 470 | (defgroup org-time nil | 487 | (defgroup org-time nil |
| 471 | "Options concerning time stamps and deadlines in Org-mode." | 488 | "Options concerning time stamps and deadlines in Org-mode." |
| 472 | :tag "Org Time" | 489 | :tag "Org Time" |
| @@ -540,7 +557,7 @@ When nil, always start on the current day." | |||
| 540 | :type 'number) | 557 | :type 'number) |
| 541 | 558 | ||
| 542 | (defcustom org-agenda-include-all-todo t | 559 | (defcustom org-agenda-include-all-todo t |
| 543 | "Non-nil means, the multifile agenda will always contain alm TODO entries. | 560 | "Non-nil means, the multifile agenda will always contain all TODO entries. |
| 544 | When nil, date-less entries will only be shown if `org-agenda' is called | 561 | When nil, date-less entries will only be shown if `org-agenda' is called |
| 545 | with a prefix argument. | 562 | with a prefix argument. |
| 546 | When non-nil, the TODO entries will be listed at the top of the agenda, before | 563 | When non-nil, the TODO entries will be listed at the top of the agenda, before |
| @@ -639,6 +656,18 @@ t Everywhere except in headlines" | |||
| 639 | "Formats for `format-time-string' which are used for time stamps. | 656 | "Formats for `format-time-string' which are used for time stamps. |
| 640 | It is not recommended to change this constant.") | 657 | It is not recommended to change this constant.") |
| 641 | 658 | ||
| 659 | (defcustom org-show-following-heading t | ||
| 660 | "Non-nil means, show heading following match in `org-occur'. | ||
| 661 | When doing an `org-occur' it is useful to show the headline which | ||
| 662 | follows the match, even if they do not match the regexp. This makes it | ||
| 663 | easier to edit directly inside the sparse tree. However, if you use | ||
| 664 | org-occur mainly as an overview, the following headlines are | ||
| 665 | unnecessary clutter." | ||
| 666 | :group 'org-structure | ||
| 667 | :type 'boolean) | ||
| 668 | |||
| 669 | |||
| 670 | |||
| 642 | (defgroup org-link nil | 671 | (defgroup org-link nil |
| 643 | "Options concerning links in Org-mode." | 672 | "Options concerning links in Org-mode." |
| 644 | :tag "Org Link" | 673 | :tag "Org Link" |
| @@ -845,11 +874,34 @@ When nil, new notes will be filed to the end of a file or entry." | |||
| 845 | :tag "Org Table" | 874 | :tag "Org Table" |
| 846 | :group 'org) | 875 | :group 'org) |
| 847 | 876 | ||
| 848 | (defcustom org-enable-table-editor t | 877 | (defcustom org-enable-table-editor 'optimized |
| 849 | "Non-nil means, lines starting with \"|\" are handled by the table editor. | 878 | "Non-nil means, lines starting with \"|\" are handled by the table editor. |
| 850 | When nil, such lines will be treated like ordinary lines." | 879 | When nil, such lines will be treated like ordinary lines. |
| 880 | |||
| 881 | When equal to the symbol `optimized', the table editor will be optimized to | ||
| 882 | do the following | ||
| 883 | - Use automatic overwrite mode in front of whitespace in table fields. | ||
| 884 | This make the structure of the table stay in tact as long as the edited | ||
| 885 | field does not exceed the column width. | ||
| 886 | - Minimize the number of realigns. Normally, the table is aligned each time | ||
| 887 | TAB or RET are pressed to move to another field. With optimization this | ||
| 888 | happens only if changes to a field might have changed the column width. | ||
| 889 | Optimization requires replacing the functions `self-insert-command', | ||
| 890 | `delete-char', and `backward-delete-char' in Org-mode buffers, with a | ||
| 891 | slight (in fact: unnoticable) speed impact for normal typing. Org-mode is | ||
| 892 | very good at guessing when a re-align will be necessary, but you can always | ||
| 893 | force one with `C-c C-c'. | ||
| 894 | |||
| 895 | I you would like to use the optimized version in Org-mode, but the un-optimized | ||
| 896 | version in OrgTbl-mode, see the variable `orgtbl-optimized'. | ||
| 897 | |||
| 898 | This variable can be used to turn on and off the table editor during a session, | ||
| 899 | but in order to toggle optimization, a restart is required." | ||
| 851 | :group 'org-table | 900 | :group 'org-table |
| 852 | :type 'boolean) | 901 | :type '(choice |
| 902 | (const :tag "off" nil) | ||
| 903 | (const :tag "on" t) | ||
| 904 | (const :tag "on, optimized" optimized))) | ||
| 853 | 905 | ||
| 854 | (defcustom org-table-default-size "5x2" | 906 | (defcustom org-table-default-size "5x2" |
| 855 | "The default size for newly created tables, Columns x Rows." | 907 | "The default size for newly created tables, Columns x Rows." |
| @@ -1295,6 +1347,8 @@ Otherwise, the buffer will just be saved to a file and stay hidden." | |||
| 1295 | (eval-when-compile | 1347 | (eval-when-compile |
| 1296 | (defvar zmacs-regions) | 1348 | (defvar zmacs-regions) |
| 1297 | (defvar org-transient-mark-mode) | 1349 | (defvar org-transient-mark-mode) |
| 1350 | (defvar org-old-auto-fill-inhibit-regexp) | ||
| 1351 | (defvar orgtbl-mode-menu) | ||
| 1298 | (defvar org-html-entities) | 1352 | (defvar org-html-entities) |
| 1299 | (defvar org-goto-start-pos) | 1353 | (defvar org-goto-start-pos) |
| 1300 | (defvar org-cursor-color) | 1354 | (defvar org-cursor-color) |
| @@ -1351,7 +1405,7 @@ messages (Gnus), BBDB entries, and any files related to the project. | |||
| 1351 | For printing and sharing of notes, an Org-mode file (or a part of it) | 1405 | For printing and sharing of notes, an Org-mode file (or a part of it) |
| 1352 | can be exported as a well-structured ASCII or HTML file. | 1406 | can be exported as a well-structured ASCII or HTML file. |
| 1353 | 1407 | ||
| 1354 | + The following commands are available: | 1408 | The following commands are available: |
| 1355 | 1409 | ||
| 1356 | \\{org-mode-map}" | 1410 | \\{org-mode-map}" |
| 1357 | (interactive "P") | 1411 | (interactive "P") |
| @@ -1363,10 +1417,12 @@ can be exported as a well-structured ASCII or HTML file. | |||
| 1363 | (org-install-agenda-files-menu) | 1417 | (org-install-agenda-files-menu) |
| 1364 | (setq outline-regexp "\\*+") | 1418 | (setq outline-regexp "\\*+") |
| 1365 | (if org-startup-truncated (setq truncate-lines t)) | 1419 | (if org-startup-truncated (setq truncate-lines t)) |
| 1366 | (org-set-regexps) | 1420 | (org-set-regexps-and-options) |
| 1367 | (set (make-local-variable 'font-lock-unfontify-region-function) | 1421 | (set (make-local-variable 'font-lock-unfontify-region-function) |
| 1368 | 'org-unfontify-region) | 1422 | 'org-unfontify-region) |
| 1369 | ;; Activate before-change-function | 1423 | ;; Activate before-change-function |
| 1424 | (set (make-local-variable 'org-table-may-need-update) t) | ||
| 1425 | (make-local-hook 'before-change-functions) ;; needed for XEmacs | ||
| 1370 | (add-hook 'before-change-functions 'org-before-change-function nil | 1426 | (add-hook 'before-change-functions 'org-before-change-function nil |
| 1371 | 'local) | 1427 | 'local) |
| 1372 | ;; Inhibit auto-fill for headers, tables and fixed-width lines. | 1428 | ;; Inhibit auto-fill for headers, tables and fixed-width lines. |
| @@ -1540,7 +1596,9 @@ can be exported as a well-structured ASCII or HTML file. | |||
| 1540 | ((org-at-table-p 'any) | 1596 | ((org-at-table-p 'any) |
| 1541 | ;; Enter the table or move to the next field in the table | 1597 | ;; Enter the table or move to the next field in the table |
| 1542 | (or (org-table-recognize-table.el) | 1598 | (or (org-table-recognize-table.el) |
| 1543 | (org-table-next-field))) | 1599 | (progn |
| 1600 | (org-table-justify-field-maybe) | ||
| 1601 | (org-table-next-field)))) | ||
| 1544 | 1602 | ||
| 1545 | (arg ;; Global cycling | 1603 | (arg ;; Global cycling |
| 1546 | 1604 | ||
| @@ -1765,9 +1823,9 @@ or nil." | |||
| 1765 | (defvar org-ignore-region nil | 1823 | (defvar org-ignore-region nil |
| 1766 | "To temporary disable the active region.") | 1824 | "To temporary disable the active region.") |
| 1767 | 1825 | ||
| 1768 | (defun org-insert-heading () | 1826 | (defun org-insert-heading (arg) |
| 1769 | "Insert a new heading with same depth at point." | 1827 | "Insert a new heading with same depth at point." |
| 1770 | (interactive) | 1828 | (interactive "P") |
| 1771 | (let* ((head (save-excursion | 1829 | (let* ((head (save-excursion |
| 1772 | (condition-case nil | 1830 | (condition-case nil |
| 1773 | (org-back-to-heading) | 1831 | (org-back-to-heading) |
| @@ -2271,14 +2329,14 @@ that the match should indeed be shown." | |||
| 2271 | (message "%d match(es) for regexp %s" cnt regexp)) | 2329 | (message "%d match(es) for regexp %s" cnt regexp)) |
| 2272 | cnt)) | 2330 | cnt)) |
| 2273 | 2331 | ||
| 2274 | |||
| 2275 | (defun org-show-hierarchy-above () | 2332 | (defun org-show-hierarchy-above () |
| 2276 | "Make sure point and the headings hierarchy above is visible." | 2333 | "Make sure point and the headings hierarchy above is visible." |
| 2277 | (if (org-on-heading-p t) | 2334 | (if (org-on-heading-p t) |
| 2278 | (org-flag-heading nil) ; only show the heading | 2335 | (org-flag-heading nil) ; only show the heading |
| 2279 | (org-show-hidden-entry)) ; show entire entry | 2336 | (org-show-hidden-entry)) ; show entire entry |
| 2280 | (save-excursion | 2337 | (save-excursion |
| 2281 | (and (outline-next-heading) | 2338 | (and org-show-following-heading |
| 2339 | (outline-next-heading) | ||
| 2282 | (org-flag-heading nil))) ; show the next heading | 2340 | (org-flag-heading nil))) ; show the next heading |
| 2283 | (save-excursion ; show all higher headings | 2341 | (save-excursion ; show all higher headings |
| 2284 | (while (condition-case nil | 2342 | (while (condition-case nil |
| @@ -2361,7 +2419,7 @@ Otherwise, only the date will be included. All parts of a date not | |||
| 2361 | specified by the user will be filled in from the current date/time. | 2419 | specified by the user will be filled in from the current date/time. |
| 2362 | So if you press just return without typing anything, the time stamp | 2420 | So if you press just return without typing anything, the time stamp |
| 2363 | will represent the current date/time. If there is already a timestamp | 2421 | will represent the current date/time. If there is already a timestamp |
| 2364 | at the cursoe, it will be modified." | 2422 | at the cursor, it will be modified." |
| 2365 | (interactive "P") | 2423 | (interactive "P") |
| 2366 | (let ((fmt (if arg (cdr org-time-stamp-formats) | 2424 | (let ((fmt (if arg (cdr org-time-stamp-formats) |
| 2367 | (car org-time-stamp-formats))) | 2425 | (car org-time-stamp-formats))) |
| @@ -2798,7 +2856,11 @@ If there is already a time stamp at the cursor position, update it." | |||
| 2798 | 2856 | ||
| 2799 | ;;;###autoload | 2857 | ;;;###autoload |
| 2800 | (defun org-agenda-mode () | 2858 | (defun org-agenda-mode () |
| 2801 | "Mode for time-sorted view on action items in Org-mode files." | 2859 | "Mode for time-sorted view on action items in Org-mode files. |
| 2860 | |||
| 2861 | The following commands are available: | ||
| 2862 | |||
| 2863 | \\{org-agenda-mode-map}" | ||
| 2802 | (interactive) | 2864 | (interactive) |
| 2803 | (kill-all-local-variables) | 2865 | (kill-all-local-variables) |
| 2804 | (setq major-mode 'org-agenda-mode) | 2866 | (setq major-mode 'org-agenda-mode) |
| @@ -3118,7 +3180,7 @@ NDAYS defaults to `org-agenda-ndays'." | |||
| 3118 | (defun org-check-agenda-file (file) | 3180 | (defun org-check-agenda-file (file) |
| 3119 | "Make sure FILE exists. If not, ask user what to do." | 3181 | "Make sure FILE exists. If not, ask user what to do." |
| 3120 | ;; FIXME: this does not correctly change the menus | 3182 | ;; FIXME: this does not correctly change the menus |
| 3121 | ;; Could be fixed by explicitly going to the buffer, maybe. | 3183 | ;; Could probably be fixed by explicitly going to the buffer. |
| 3122 | (when (not (file-exists-p file)) | 3184 | (when (not (file-exists-p file)) |
| 3123 | (message "non-existent file %s. [R]emove from agenda-files or [A]bort?" | 3185 | (message "non-existent file %s. [R]emove from agenda-files or [A]bort?" |
| 3124 | file) | 3186 | file) |
| @@ -4507,7 +4569,6 @@ RET at beg-of-buf -> Append to file as level 2 headline | |||
| 4507 | RET on headline -> Store as sublevel entry to current headline | 4569 | RET on headline -> Store as sublevel entry to current headline |
| 4508 | <left>/<right> -> before/after current headline, same headings level") | 4570 | <left>/<right> -> before/after current headline, same headings level") |
| 4509 | 4571 | ||
| 4510 | ;; FIXME: Document C-u C-c C-c | ||
| 4511 | ;;;###autoload | 4572 | ;;;###autoload |
| 4512 | (defun org-remember-handler () | 4573 | (defun org-remember-handler () |
| 4513 | "Store stuff from remember.el into an org file. | 4574 | "Store stuff from remember.el into an org file. |
| @@ -4796,6 +4857,21 @@ Such a file can be imported into a spreadsheet program like Excel." | |||
| 4796 | (save-buffer)) | 4857 | (save-buffer)) |
| 4797 | (kill-buffer buf))) | 4858 | (kill-buffer buf))) |
| 4798 | 4859 | ||
| 4860 | (defvar org-table-aligned-begin-marker (make-marker) | ||
| 4861 | "Marker at the beginning of the table last aligned. | ||
| 4862 | Used to check if cursor still is in that table, to minimize realignment.") | ||
| 4863 | (defvar org-table-aligned-end-marker (make-marker) | ||
| 4864 | "Marker at the end of the table last aligned. | ||
| 4865 | Used to check if cursor still is in that table, to minimize realignment.") | ||
| 4866 | (defvar org-table-last-alignment nil | ||
| 4867 | "List of flags for flushright alignment, from the last re-algnment. | ||
| 4868 | This is being used to correctly align a single field after TAB or RET.") | ||
| 4869 | ;; FIXME: The following is currently not used. | ||
| 4870 | (defvar org-table-last-column-widths nil | ||
| 4871 | "List of max width of ffields in each column. | ||
| 4872 | This is being used to correctly align a single field after TAB or RET.") | ||
| 4873 | |||
| 4874 | |||
| 4799 | (defun org-table-align (&optional arg) | 4875 | (defun org-table-align (&optional arg) |
| 4800 | "Align the table at point by aligning all vertical bars." | 4876 | "Align the table at point by aligning all vertical bars." |
| 4801 | (interactive "P") | 4877 | (interactive "P") |
| @@ -4866,6 +4942,8 @@ Such a file can be imported into a spreadsheet program like Excel." | |||
| 4866 | (push (>= frac org-table-number-fraction) typenums)) | 4942 | (push (>= frac org-table-number-fraction) typenums)) |
| 4867 | (setq lengths (nreverse lengths) | 4943 | (setq lengths (nreverse lengths) |
| 4868 | typenums (nreverse typenums)) | 4944 | typenums (nreverse typenums)) |
| 4945 | (setq org-table-last-alignment typenums | ||
| 4946 | org-table-last-column-widths lengths) | ||
| 4869 | ;; Compute the formats needed for output of the table | 4947 | ;; Compute the formats needed for output of the table |
| 4870 | (setq rfmt (concat indent "|") hfmt (concat indent "|")) | 4948 | (setq rfmt (concat indent "|") hfmt (concat indent "|")) |
| 4871 | (while (setq l (pop lengths)) | 4949 | (while (setq l (pop lengths)) |
| @@ -4884,13 +4962,14 @@ Such a file can be imported into a spreadsheet program like Excel." | |||
| 4884 | ;; Replace the old one | 4962 | ;; Replace the old one |
| 4885 | (delete-region beg end) | 4963 | (delete-region beg end) |
| 4886 | (move-marker end nil) | 4964 | (move-marker end nil) |
| 4965 | (move-marker org-table-aligned-begin-marker (point)) | ||
| 4887 | (insert new) | 4966 | (insert new) |
| 4967 | (move-marker org-table-aligned-end-marker (point)) | ||
| 4888 | ;; Try to move to the old location (approximately) | 4968 | ;; Try to move to the old location (approximately) |
| 4889 | (goto-line linepos) | 4969 | (goto-line linepos) |
| 4890 | (set-window-start (selected-window) winstart 'noforce) | 4970 | (set-window-start (selected-window) winstart 'noforce) |
| 4891 | (org-table-goto-column colpos) | 4971 | (org-table-goto-column colpos) |
| 4892 | (setq org-table-may-need-update nil) | 4972 | (setq org-table-may-need-update nil) |
| 4893 | ;; (message "Aligning table...done") | ||
| 4894 | (if (org-in-invisibility-spec-p '(org-table)) | 4973 | (if (org-in-invisibility-spec-p '(org-table)) |
| 4895 | (org-table-add-invisible-to-vertical-lines)) | 4974 | (org-table-add-invisible-to-vertical-lines)) |
| 4896 | )) | 4975 | )) |
| @@ -4920,6 +4999,35 @@ With argument TABLE-TYPE, go to the end of a table.el-type table." | |||
| 4920 | (goto-char (match-beginning 0))) | 4999 | (goto-char (match-beginning 0))) |
| 4921 | (point-marker))) | 5000 | (point-marker))) |
| 4922 | 5001 | ||
| 5002 | (defun org-table-justify-field-maybe () | ||
| 5003 | "Justify the current field, text to left, number to right." | ||
| 5004 | (cond | ||
| 5005 | (org-table-may-need-update) ; Realignment will happen anyway, don't bother | ||
| 5006 | ((org-at-table-hline-p) | ||
| 5007 | ;; This is pretty stupid, but I don't know how to deal with hlines | ||
| 5008 | (setq org-table-may-need-update t)) | ||
| 5009 | ((or (not (equal (marker-buffer org-table-aligned-begin-marker) | ||
| 5010 | (current-buffer))) | ||
| 5011 | (< (point) org-table-aligned-begin-marker) | ||
| 5012 | (>= (point) org-table-aligned-end-marker)) | ||
| 5013 | ;; This is not the same table, force a full re-align | ||
| 5014 | (setq org-table-may-need-update t)) | ||
| 5015 | (t ;; realign the current field, based on previous full realign | ||
| 5016 | (let* ((pos (point)) s org-table-may-need-update | ||
| 5017 | (col (org-table-current-column)) | ||
| 5018 | (num (nth (1- col) org-table-last-alignment)) | ||
| 5019 | l f) | ||
| 5020 | (when (> col 0) | ||
| 5021 | (skip-chars-backward "^|\n") | ||
| 5022 | (if (looking-at " *\\([^|\n]*?\\) *|") | ||
| 5023 | (progn | ||
| 5024 | (setq s (match-string 1) | ||
| 5025 | l (max 1 (- (match-end 0) (match-beginning 0) 3))) | ||
| 5026 | (setq f (format (if num " %%%ds |" " %%-%ds |") l)) | ||
| 5027 | (replace-match (format f s t t))) | ||
| 5028 | (setq org-table-may-need-update t)) | ||
| 5029 | (goto-char pos)))))) | ||
| 5030 | |||
| 4923 | (defun org-table-next-field (&optional arg) | 5031 | (defun org-table-next-field (&optional arg) |
| 4924 | "Go to the next field in the current table. | 5032 | "Go to the next field in the current table. |
| 4925 | Before doing so, re-align the table if necessary." | 5033 | Before doing so, re-align the table if necessary." |
| @@ -5013,18 +5121,21 @@ I.e. not on a hline or before the first or after the last column?" | |||
| 5013 | (error "Not in table data field"))) | 5121 | (error "Not in table data field"))) |
| 5014 | 5122 | ||
| 5015 | (defun org-table-blank-field () | 5123 | (defun org-table-blank-field () |
| 5016 | "Blank the current table field." | 5124 | "Blank the current table field or active region." |
| 5017 | (interactive) | 5125 | (interactive) |
| 5018 | (org-table-check-inside-data-field) | 5126 | (org-table-check-inside-data-field) |
| 5019 | (skip-chars-backward "^|") | 5127 | (if (and (interactive-p) (org-region-active-p)) |
| 5020 | (backward-char 1) | 5128 | (let (org-table-clip) |
| 5021 | (if (looking-at "|[^|]+") | 5129 | (org-table-cut-region)) |
| 5022 | (let* ((pos (match-beginning 0)) | 5130 | (skip-chars-backward "^|") |
| 5023 | (match (match-string 0)) | 5131 | (backward-char 1) |
| 5024 | (len (length match))) | 5132 | (if (looking-at "|[^|]+") |
| 5025 | (replace-match (concat "|" (make-string (1- len) ?\ ))) | 5133 | (let* ((pos (match-beginning 0)) |
| 5026 | (goto-char (+ 2 pos)) | 5134 | (match (match-string 0)) |
| 5027 | (substring match 1)))) | 5135 | (len (length match))) |
| 5136 | (replace-match (concat "|" (make-string (1- len) ?\ ))) | ||
| 5137 | (goto-char (+ 2 pos)) | ||
| 5138 | (substring match 1))))) | ||
| 5028 | 5139 | ||
| 5029 | (defun org-table-get-field (&optional n replace) | 5140 | (defun org-table-get-field (&optional n replace) |
| 5030 | "Return the value of the field in column N of current row. | 5141 | "Return the value of the field in column N of current row. |
| @@ -5199,6 +5310,15 @@ However, when FORCE is non-nil, create new columns if necessary." | |||
| 5199 | (org-table-goto-column colpos)) | 5310 | (org-table-goto-column colpos)) |
| 5200 | (org-table-align)) | 5311 | (org-table-align)) |
| 5201 | 5312 | ||
| 5313 | (defun org-table-move-column-right () | ||
| 5314 | "Move column to the right." | ||
| 5315 | (interactive) | ||
| 5316 | (org-table-move-column nil)) | ||
| 5317 | (defun org-table-move-column-left () | ||
| 5318 | "Move column to the left." | ||
| 5319 | (interactive) | ||
| 5320 | (org-table-move-column 'left)) | ||
| 5321 | |||
| 5202 | (defun org-table-move-column (&optional left) | 5322 | (defun org-table-move-column (&optional left) |
| 5203 | "Move the current column to the right. With arg LEFT, move to the left." | 5323 | "Move the current column to the right. With arg LEFT, move to the left." |
| 5204 | (interactive "P") | 5324 | (interactive "P") |
| @@ -5230,6 +5350,15 @@ However, when FORCE is non-nil, create new columns if necessary." | |||
| 5230 | (org-table-goto-column colpos)) | 5350 | (org-table-goto-column colpos)) |
| 5231 | (org-table-align)) | 5351 | (org-table-align)) |
| 5232 | 5352 | ||
| 5353 | (defun org-table-move-row-down () | ||
| 5354 | "Move table row down." | ||
| 5355 | (interactive) | ||
| 5356 | (org-table-move-row nil)) | ||
| 5357 | (defun org-table-move-row-up () | ||
| 5358 | "Move table row down." | ||
| 5359 | (interactive) | ||
| 5360 | (org-table-move-row 'up)) | ||
| 5361 | |||
| 5233 | (defun org-table-move-row (&optional up) | 5362 | (defun org-table-move-row (&optional up) |
| 5234 | "Move the current table line down. With arg UP, move it up." | 5363 | "Move the current table line down. With arg UP, move it up." |
| 5235 | (interactive "P") | 5364 | (interactive "P") |
| @@ -5263,11 +5392,12 @@ With prefix ARG, insert below the current line." | |||
| 5263 | (setq line (mapcar (lambda (x) (if (member x '(?| ?+)) ?| ?\ )) line)) | 5392 | (setq line (mapcar (lambda (x) (if (member x '(?| ?+)) ?| ?\ )) line)) |
| 5264 | (setq line (mapcar (lambda (x) (if (equal x ?|) ?| ?\ )) line))) | 5393 | (setq line (mapcar (lambda (x) (if (equal x ?|) ?| ?\ )) line))) |
| 5265 | (beginning-of-line (if arg 2 1)) | 5394 | (beginning-of-line (if arg 2 1)) |
| 5266 | (apply 'insert line) | 5395 | (let (org-table-may-need-update) |
| 5267 | (insert "\n") | 5396 | (apply 'insert-before-markers line) |
| 5397 | (insert-before-markers "\n")) | ||
| 5268 | (beginning-of-line 0) | 5398 | (beginning-of-line 0) |
| 5269 | (re-search-forward "| ?" (point-at-eol) t) | 5399 | (re-search-forward "| ?" (point-at-eol) t) |
| 5270 | (org-table-align))) | 5400 | (and org-table-may-need-update (org-table-align)))) |
| 5271 | 5401 | ||
| 5272 | (defun org-table-insert-hline (&optional arg) | 5402 | (defun org-table-insert-hline (&optional arg) |
| 5273 | "Insert a horizontal-line below the current line into the table. | 5403 | "Insert a horizontal-line below the current line into the table. |
| @@ -5788,6 +5918,271 @@ separator line)." | |||
| 5788 | (setq ndown 0))) | 5918 | (setq ndown 0))) |
| 5789 | (org-table-align))) | 5919 | (org-table-align))) |
| 5790 | 5920 | ||
| 5921 | ;;; The orgtbl minor mode | ||
| 5922 | |||
| 5923 | ;; Define a minor mode which can be used in other modes in order to | ||
| 5924 | ;; integrate the org-mode table editor. | ||
| 5925 | |||
| 5926 | ;; This is really a hack, because the org-mode table editor uses several | ||
| 5927 | ;; keys which normally belong to the major mode, for example the TAB and | ||
| 5928 | ;; RET keys. Here is how it works: The minor mode defines all the keys | ||
| 5929 | ;; necessary to operate the table editor, but wraps the commands into a | ||
| 5930 | ;; function which tests if the cursor is currently inside a table. If that | ||
| 5931 | ;; is the case, the table editor command is executed. However, when any of | ||
| 5932 | ;; those keys is used outside a table, the function uses `key-binding' to | ||
| 5933 | ;; look up if the key has an associated command in another currently active | ||
| 5934 | ;; keymap (minor modes, major mode, global), and executes that command. | ||
| 5935 | ;; There might be problems if any of the keys used by the table editor is | ||
| 5936 | ;; otherwise used as a prefix key. | ||
| 5937 | |||
| 5938 | ;; Another challenge is that the key binding for TAB can be tab or \C-i, | ||
| 5939 | ;; likewise the binding for RET can be return or \C-m. Orgtbl-mode | ||
| 5940 | ;; addresses this by checking explicitly for both bindings. | ||
| 5941 | |||
| 5942 | ;; The optimized version (see variable `orgtbl-optimized') takes over | ||
| 5943 | ;; all keys which are bound to `self-insert-command' in the *global map*. | ||
| 5944 | ;; Some modes bind other commands to simple characters, for example | ||
| 5945 | ;; AUCTeX binds the double quote to `Tex-insert-quote'. With orgtbl-mode | ||
| 5946 | ;; active, this binding is ignored inside tables and replaced with a | ||
| 5947 | ;; modified self-insert. | ||
| 5948 | |||
| 5949 | (defcustom orgtbl-optimized (eq org-enable-table-editor 'optimized) | ||
| 5950 | "Non-nil means, use the optimized table editor version for orgtbl-mode. | ||
| 5951 | In the optimized version, the table editor takes over all simple keys that | ||
| 5952 | normally just insert a character. In tables, the characters are inserted | ||
| 5953 | in a way to minimize disturbing the table structure (i.e. in overwrite mode | ||
| 5954 | for empty fields). Outside tables, the correct binding of the keys is | ||
| 5955 | restored. | ||
| 5956 | |||
| 5957 | The default for this option is t if the optimized version is also used in | ||
| 5958 | Org-mode. See the variable `org-enable-table-editor' for details. Changing | ||
| 5959 | this variable requires a restart of Emacs to become effective." | ||
| 5960 | :group 'org-table | ||
| 5961 | :type 'boolean) | ||
| 5962 | |||
| 5963 | (defvar orgtbl-mode nil | ||
| 5964 | "Variable controlling orgtbl-mode, a minor mode enabling the org-mode | ||
| 5965 | table editor iin arbitrary modes.") | ||
| 5966 | (make-variable-buffer-local 'orgtbl-mode) | ||
| 5967 | |||
| 5968 | (defvar orgtbl-mode-map (make-sparse-keymap) | ||
| 5969 | "Keymap for orgtbl-mode.") | ||
| 5970 | |||
| 5971 | ;;;###autoload | ||
| 5972 | (defun turn-on-orgtbl () | ||
| 5973 | "Unconditionally turn on orgtbl-mode." | ||
| 5974 | (orgtbl-mode 1)) | ||
| 5975 | |||
| 5976 | ;;;###autoload | ||
| 5977 | (defun orgtbl-mode (&optional arg) | ||
| 5978 | "The org-mode table editor as a minor mode for use in other modes." | ||
| 5979 | (interactive) | ||
| 5980 | (setq orgtbl-mode | ||
| 5981 | (if arg (> (prefix-numeric-value arg) 0) (not orgtbl-mode))) | ||
| 5982 | (if orgtbl-mode | ||
| 5983 | (progn | ||
| 5984 | (set (make-local-variable (quote org-table-may-need-update)) t) | ||
| 5985 | (make-local-hook (quote before-change-functions)) | ||
| 5986 | (add-hook 'before-change-functions 'org-before-change-function | ||
| 5987 | nil 'local) | ||
| 5988 | (set (make-local-variable 'org-old-auto-fill-inhibit-regexp) | ||
| 5989 | auto-fill-inhibit-regexp) | ||
| 5990 | (set (make-local-variable 'auto-fill-inhibit-regexp) | ||
| 5991 | (if auto-fill-inhibit-regexp | ||
| 5992 | (concat "\\([ \t]*|\\|" auto-fill-inhibit-regexp) | ||
| 5993 | "[ \t]*|")) | ||
| 5994 | (easy-menu-add orgtbl-mode-menu) | ||
| 5995 | (run-hooks (quote orgtbl-mode-hook))) | ||
| 5996 | (setq auto-fill-inhibit-regexp org-old-auto-fill-inhibit-regexp) | ||
| 5997 | (remove-hook 'before-change-functions 'org-before-change-function t) | ||
| 5998 | (easy-menu-remove orgtbl-mode-menu) | ||
| 5999 | (force-mode-line-update 'all))) | ||
| 6000 | |||
| 6001 | ;; Install it as a minor mode. | ||
| 6002 | (put 'orgtbl-mode :included t) | ||
| 6003 | (put 'orgtbl-mode :menu-tag "Org Table Mode") | ||
| 6004 | (add-minor-mode 'orgtbl-mode " OrgTbl" orgtbl-mode-map) | ||
| 6005 | |||
| 6006 | (defun orgtbl-make-binding (fun &rest keys) | ||
| 6007 | "Create a function for binding in the table minor mode." | ||
| 6008 | (list 'lambda '(arg) '(interactive "p") | ||
| 6009 | (list 'if | ||
| 6010 | '(org-at-table-p) | ||
| 6011 | (list 'call-interactively (list 'quote fun)) | ||
| 6012 | (list 'let '(orgtbl-mode) | ||
| 6013 | (list 'call-interactively | ||
| 6014 | (append '(or) | ||
| 6015 | (mapcar (lambda (k) | ||
| 6016 | (list 'key-binding k)) | ||
| 6017 | keys) | ||
| 6018 | '('orgtbl-error))))))) | ||
| 6019 | |||
| 6020 | (defun orgtbl-error () | ||
| 6021 | "Error when there is no default binding for a table key." | ||
| 6022 | (interactive) | ||
| 6023 | (error "This key is has no function outside tables")) | ||
| 6024 | |||
| 6025 | ;; Keybindings for the minor mode | ||
| 6026 | (let ((bindings | ||
| 6027 | '(([(meta shift left)] org-table-delete-column) | ||
| 6028 | ([(meta left)] org-table-move-column-left) | ||
| 6029 | ([(meta right)] org-table-move-column-right) | ||
| 6030 | ([(meta shift right)] org-table-insert-column) | ||
| 6031 | ([(meta shift up)] org-table-kill-row) | ||
| 6032 | ([(meta shift down)] org-table-insert-row) | ||
| 6033 | ([(meta up)] org-table-move-row-up) | ||
| 6034 | ([(meta down)] org-table-move-row-down) | ||
| 6035 | ("\C-c\C-w" org-table-cut-region) | ||
| 6036 | ("\C-c\M-w" org-table-copy-region) | ||
| 6037 | ("\C-c\C-y" org-table-paste-rectangle) | ||
| 6038 | ("\C-c-" org-table-insert-hline) | ||
| 6039 | ([(shift tab)] org-table-previous-field) | ||
| 6040 | ("\C-c\C-c" org-table-align) | ||
| 6041 | ([(return)] org-table-next-row) | ||
| 6042 | ([(shift return)] org-table-copy-from-above) | ||
| 6043 | ([(meta return)] org-table-wrap-region) | ||
| 6044 | ("\C-c\C-q" org-table-wrap-region) | ||
| 6045 | ("\C-c?" org-table-current-column) | ||
| 6046 | ("\C-c " org-table-blank-field) | ||
| 6047 | ("\C-c+" org-table-sum) | ||
| 6048 | ("\C-c|" org-table-toggle-vline-visibility) | ||
| 6049 | ("\C-c=" org-table-eval-formula))) | ||
| 6050 | elt key fun cmd) | ||
| 6051 | (while (setq elt (pop bindings)) | ||
| 6052 | (setq key (car elt) | ||
| 6053 | fun (nth 1 elt) | ||
| 6054 | cmd (orgtbl-make-binding fun key)) | ||
| 6055 | (define-key orgtbl-mode-map key cmd))) | ||
| 6056 | |||
| 6057 | ;; Special treatment needed for TAB and RET | ||
| 6058 | ;(define-key orgtbl-mode-map [(return)] | ||
| 6059 | ; (orgtbl-make-binding 'org-table-next-row [(return)] "\C-m")) | ||
| 6060 | ;(define-key orgtbl-mode-map "\C-m" | ||
| 6061 | ; (orgtbl-make-binding 'org-table-next-row "\C-m" [(return)])) | ||
| 6062 | ;(define-key orgtbl-mode-map [(tab)] | ||
| 6063 | ; (orgtbl-make-binding 'org-table-next-field [(tab)] "\C-i")) | ||
| 6064 | ;(define-key orgtbl-mode-map "\C-i" | ||
| 6065 | ; (orgtbl-make-binding 'org-table-next-field "\C-i" [(tab)])) | ||
| 6066 | |||
| 6067 | (define-key orgtbl-mode-map [(return)] | ||
| 6068 | (orgtbl-make-binding 'orgtbl-ret [(return)] "\C-m")) | ||
| 6069 | (define-key orgtbl-mode-map "\C-m" | ||
| 6070 | (orgtbl-make-binding 'orgtbl-ret "\C-m" [(return)])) | ||
| 6071 | (define-key orgtbl-mode-map [(tab)] | ||
| 6072 | (orgtbl-make-binding 'orgtbl-tab [(tab)] "\C-i")) | ||
| 6073 | (define-key orgtbl-mode-map "\C-i" | ||
| 6074 | (orgtbl-make-binding 'orgtbl-tab "\C-i" [(tab)])) | ||
| 6075 | |||
| 6076 | (when orgtbl-optimized | ||
| 6077 | ;; If the user wants maximum table support, we need to hijack | ||
| 6078 | ;; some standard editing functions | ||
| 6079 | (substitute-key-definition 'self-insert-command 'orgtbl-self-insert-command | ||
| 6080 | orgtbl-mode-map global-map) | ||
| 6081 | (substitute-key-definition 'delete-char 'orgtbl-delete-char | ||
| 6082 | orgtbl-mode-map global-map) | ||
| 6083 | (substitute-key-definition 'delete-backward-char 'orgtbl-delete-backward-char | ||
| 6084 | orgtbl-mode-map global-map) | ||
| 6085 | (define-key org-mode-map "|" 'self-insert-command)) | ||
| 6086 | |||
| 6087 | (defun orgtbl-tab () | ||
| 6088 | "Justification and field motion for orgtbl-mode." | ||
| 6089 | (interactive) | ||
| 6090 | (org-table-justify-field-maybe) | ||
| 6091 | (org-table-next-field)) | ||
| 6092 | |||
| 6093 | (defun orgtbl-ret () | ||
| 6094 | "Justification and field motion for orgtbl-mode." | ||
| 6095 | (interactive) | ||
| 6096 | (org-table-justify-field-maybe) | ||
| 6097 | (org-table-next-row)) | ||
| 6098 | |||
| 6099 | (defun orgtbl-self-insert-command (N) | ||
| 6100 | "Like `self-insert-command', use overwrite-mode for whitespace in tables. | ||
| 6101 | If the cursor is in a table looking at whitespace, the whitespace is | ||
| 6102 | overwritten, and the table is not marked as requiring realignment." | ||
| 6103 | (interactive "p") | ||
| 6104 | (if (and (org-at-table-p) | ||
| 6105 | (eq N 1) | ||
| 6106 | (looking-at "[^|\n]* +|")) | ||
| 6107 | (let (org-table-may-need-update (pos (point))) | ||
| 6108 | (goto-char (1- (match-end 0))) | ||
| 6109 | (delete-backward-char 1) | ||
| 6110 | (goto-char (match-beginning 0)) | ||
| 6111 | (self-insert-command N)) | ||
| 6112 | (setq org-table-may-need-update t) | ||
| 6113 | (let (orgtbl-mode) | ||
| 6114 | (call-interactively (key-binding (vector last-input-event)))))) | ||
| 6115 | |||
| 6116 | (defun orgtbl-delete-backward-char (N) | ||
| 6117 | "Like `delete-backward-char', insert whitespace at field end in tables. | ||
| 6118 | When deleting backwards, in tables this function will insert whitespace in | ||
| 6119 | front of the next \"|\" separator, to keep the table aligned. The table will | ||
| 6120 | still be marked for re-alignment, because a narrow field may lead to a | ||
| 6121 | reduced column width." | ||
| 6122 | (interactive "p") | ||
| 6123 | (if (and (org-at-table-p) | ||
| 6124 | (eq N 1) | ||
| 6125 | (looking-at ".*?|")) | ||
| 6126 | (let ((pos (point))) | ||
| 6127 | (backward-delete-char N) | ||
| 6128 | (skip-chars-forward "^|") | ||
| 6129 | (insert " ") | ||
| 6130 | (goto-char (1- pos))) | ||
| 6131 | (message "%s" last-input-event) (sit-for 1) | ||
| 6132 | (delete-backward-char N))) | ||
| 6133 | |||
| 6134 | (defun orgtbl-delete-char (N) | ||
| 6135 | "Like `delete-char', but insert whitespace at field end in tables. | ||
| 6136 | When deleting characters, in tables this function will insert whitespace in | ||
| 6137 | front of the next \"|\" separator, to keep the table aligned. The table | ||
| 6138 | will still be marked for re-alignment, because a narrow field may lead to | ||
| 6139 | a reduced column width." | ||
| 6140 | (interactive "p") | ||
| 6141 | (if (and (org-at-table-p) | ||
| 6142 | (eq N 1)) | ||
| 6143 | (if (looking-at ".*?|") | ||
| 6144 | (let ((pos (point))) | ||
| 6145 | (replace-match (concat | ||
| 6146 | (substring (match-string 0) 1 -1) | ||
| 6147 | " |")) | ||
| 6148 | (goto-char pos))) | ||
| 6149 | (delete-char N))) | ||
| 6150 | |||
| 6151 | (easy-menu-define orgtbl-mode-menu orgtbl-mode-map "OrgTbl menu" | ||
| 6152 | '("Tbl" | ||
| 6153 | ["Align" org-ctrl-c-ctrl-c :active (org-at-table-p) :keys "C-c C-c"] | ||
| 6154 | ["Next field" org-cycle :active (org-at-table-p) :keys "TAB"] | ||
| 6155 | ["Previous Field" org-shifttab :active (org-at-table-p) :keys "S-TAB"] | ||
| 6156 | ["Next row" org-return :active (org-at-table-p) :keys "RET"] | ||
| 6157 | "--" | ||
| 6158 | ["Blank field" org-table-blank-field :active (org-at-table-p) :keys "C-c SPC"] | ||
| 6159 | ["Copy field from above" | ||
| 6160 | org-table-copy-from-above :active (org-at-table-p) :keys "S-RET"] | ||
| 6161 | "--" | ||
| 6162 | ("Column" | ||
| 6163 | ["Move column left" org-metaleft :active (org-at-table-p) :keys "M-<left>"] | ||
| 6164 | ["Move column right" org-metaright :active (org-at-table-p) :keys "M-<right>"] | ||
| 6165 | ["Delete column" org-shiftmetaleft :active (org-at-table-p) :keys "M-S-<left>"] | ||
| 6166 | ["Insert column" org-shiftmetaright :active (org-at-table-p) :keys "M-S-<right>"]) | ||
| 6167 | ("Row" | ||
| 6168 | ["Move row up" org-metaup :active (org-at-table-p) :keys "M-<up>"] | ||
| 6169 | ["Move row down" org-metadown :active (org-at-table-p) :keys "M-<down>"] | ||
| 6170 | ["Delete row" org-shiftmetaup :active (org-at-table-p) :keys "M-S-<up>"] | ||
| 6171 | ["Insert row" org-shiftmetadown :active (org-at-table-p) :keys "M-S-<down>"] | ||
| 6172 | "--" | ||
| 6173 | ["Insert hline" org-table-insert-hline :active (org-at-table-p) :keys "C-c -"]) | ||
| 6174 | ("Rectangle" | ||
| 6175 | ["Copy rectangle" org-copy-special :active (org-at-table-p) :keys "C-c M-w"] | ||
| 6176 | ["Cut rectangle" org-cut-special :active (org-at-table-p) :keys "C-c C-w"] | ||
| 6177 | ["Paste rectangle" org-paste-special :active (org-at-table-p) :keys "C-c C-y"] | ||
| 6178 | ["Fill rectangle" org-table-wrap-region :active (org-at-table-p) :keys "C-c C-q"]) | ||
| 6179 | "--" | ||
| 6180 | ["Which column?" org-table-current-column :active (org-at-table-p) :keys "C-c ?"] | ||
| 6181 | ["Sum column/rectangle" org-table-sum | ||
| 6182 | :active (or (org-at-table-p) (org-region-active-p)) :keys "C-c +"] | ||
| 6183 | ["Eval formula" org-table-eval-formula :active (org-at-table-p) :keys "C-c ="] | ||
| 6184 | )) | ||
| 6185 | |||
| 5791 | ;;; Exporting | 6186 | ;;; Exporting |
| 5792 | 6187 | ||
| 5793 | (defconst org-level-max 20) | 6188 | (defconst org-level-max 20) |
| @@ -6300,6 +6695,7 @@ Does include HTML export options as well as TODO and CATEGORY stuff." | |||
| 6300 | #+CATEGORY: %s | 6695 | #+CATEGORY: %s |
| 6301 | #+SEQ_TODO: %s | 6696 | #+SEQ_TODO: %s |
| 6302 | #+TYP_TODO: %s | 6697 | #+TYP_TODO: %s |
| 6698 | #+STARTUP: %s %s | ||
| 6303 | " | 6699 | " |
| 6304 | (buffer-name) (user-full-name) user-mail-address org-export-default-language | 6700 | (buffer-name) (user-full-name) user-mail-address org-export-default-language |
| 6305 | org-export-headline-levels | 6701 | org-export-headline-levels |
| @@ -6318,7 +6714,10 @@ Does include HTML export options as well as TODO and CATEGORY stuff." | |||
| 6318 | "TODO FEEDBACK VERIFY DONE") | 6714 | "TODO FEEDBACK VERIFY DONE") |
| 6319 | (if (equal org-todo-interpretation 'type) | 6715 | (if (equal org-todo-interpretation 'type) |
| 6320 | (mapconcat 'identity org-todo-keywords " ") | 6716 | (mapconcat 'identity org-todo-keywords " ") |
| 6321 | "Me Jason Marie DONE"))) | 6717 | "Me Jason Marie DONE") |
| 6718 | (if org-startup-folded "fold" "nofold") | ||
| 6719 | (if org-startup-with-deadline-check "dlcheck" "nodlcheck") | ||
| 6720 | )) | ||
| 6322 | 6721 | ||
| 6323 | (defun org-insert-export-options-template () | 6722 | (defun org-insert-export-options-template () |
| 6324 | "Insert into the buffer a template with information for exporting." | 6723 | "Insert into the buffer a template with information for exporting." |
| @@ -7025,6 +7424,7 @@ When LEVEL is non-nil, increase section numbers on that level." | |||
| 7025 | (define-key org-mode-map "\C-c\C-c" 'org-ctrl-c-ctrl-c) | 7424 | (define-key org-mode-map "\C-c\C-c" 'org-ctrl-c-ctrl-c) |
| 7026 | (define-key org-mode-map [(return)] 'org-return) | 7425 | (define-key org-mode-map [(return)] 'org-return) |
| 7027 | (define-key org-mode-map [(shift return)] 'org-table-copy-from-above) | 7426 | (define-key org-mode-map [(shift return)] 'org-table-copy-from-above) |
| 7427 | (define-key org-mode-map [(meta return)] 'org-meta-return) | ||
| 7028 | (define-key org-mode-map [(control up)] 'org-move-line-up) | 7428 | (define-key org-mode-map [(control up)] 'org-move-line-up) |
| 7029 | (define-key org-mode-map [(control down)] 'org-move-line-down) | 7429 | (define-key org-mode-map [(control down)] 'org-move-line-down) |
| 7030 | (define-key org-mode-map "\C-c?" 'org-table-current-column) | 7430 | (define-key org-mode-map "\C-c?" 'org-table-current-column) |
| @@ -7041,6 +7441,105 @@ When LEVEL is non-nil, increase section numbers on that level." | |||
| 7041 | (define-key org-mode-map "\C-c\C-xh" 'org-export-as-html) | 7441 | (define-key org-mode-map "\C-c\C-xh" 'org-export-as-html) |
| 7042 | (define-key org-mode-map "\C-c\C-x\C-h" 'org-export-as-html-and-open) | 7442 | (define-key org-mode-map "\C-c\C-x\C-h" 'org-export-as-html-and-open) |
| 7043 | 7443 | ||
| 7444 | |||
| 7445 | ;; FIXME: Do we really need to save match data in these commands? | ||
| 7446 | ;; I would like to remove it in order to minimize impact. | ||
| 7447 | ;; Self-insert already does not preserve it. How much resources does this take??? | ||
| 7448 | |||
| 7449 | (defsubst org-table-p () | ||
| 7450 | (if (and (eq major-mode 'org-mode) font-lock-mode) | ||
| 7451 | (eq (get-text-property (point) 'face) 'org-table-face) | ||
| 7452 | (save-match-data (org-at-table-p)))) | ||
| 7453 | |||
| 7454 | (defun org-self-insert-command (N) | ||
| 7455 | "Like `self-insert-command', use overwrite-mode for whitespace in tables. | ||
| 7456 | If the cursor is in a table looking at whitespace, the whitespace is | ||
| 7457 | overwritten, and the table is not marked as requiring realignment." | ||
| 7458 | (interactive "p") | ||
| 7459 | (if (and (org-table-p) | ||
| 7460 | (eq N 1) | ||
| 7461 | (looking-at "[^|\n]* +|")) | ||
| 7462 | (let (org-table-may-need-update (pos (point))) | ||
| 7463 | (goto-char (1- (match-end 0))) | ||
| 7464 | (delete-backward-char 1) | ||
| 7465 | (goto-char (match-beginning 0)) | ||
| 7466 | (self-insert-command N)) | ||
| 7467 | (setq org-table-may-need-update t) | ||
| 7468 | (self-insert-command N))) | ||
| 7469 | |||
| 7470 | ;; FIXME: | ||
| 7471 | ;; The following two functions might still be optimized to trigger | ||
| 7472 | ;; re-alignment less frequently. Right now they raise the flag each time | ||
| 7473 | ;; (through before-change-functions). Here is how this could be minimized: | ||
| 7474 | ;; Basically, check if the non-white field width before deletion is | ||
| 7475 | ;; equal to the column width. If yes, the delete should trigger a | ||
| 7476 | ;; re-align. I have not implemented this so far because it is not so | ||
| 7477 | ;; easy, requires grabbing the field etc. So it may finally have some | ||
| 7478 | ;; impact on typing performance which we don't want. | ||
| 7479 | |||
| 7480 | ;; The defsubst is only a draft, untested... | ||
| 7481 | |||
| 7482 | ;; Maybe it is not so important to get rid of realigns - maybe the most | ||
| 7483 | ;; important aspect is to keep the table look noce as long as possible, | ||
| 7484 | ;; which is already achieved... | ||
| 7485 | |||
| 7486 | ;(defsubst org-check-delete-triggers-realign () | ||
| 7487 | ; (let ((pos (point))) | ||
| 7488 | ; (skip-chars-backward "^|\n") | ||
| 7489 | ; (and (looking-at " *\\(.*?\\) *|") | ||
| 7490 | ; (= (nth (1- (org-table-current-column)) | ||
| 7491 | ; org-table-last-column-widths) | ||
| 7492 | ; (- (match-end 1) (match-beginning 1))) | ||
| 7493 | ; (setq org-table-may-need-update t)))) | ||
| 7494 | |||
| 7495 | (defun org-delete-backward-char (N) | ||
| 7496 | "Like `delete-backward-char', insert whitespace at field end in tables. | ||
| 7497 | When deleting backwards, in tables this function will insert whitespace in | ||
| 7498 | front of the next \"|\" separator, to keep the table aligned. The table will | ||
| 7499 | still be marked for re-alignment, because a narrow field may lead to a | ||
| 7500 | reduced column width." | ||
| 7501 | (interactive "p") | ||
| 7502 | (if (and (org-table-p) | ||
| 7503 | (eq N 1) | ||
| 7504 | (looking-at ".*?|")) | ||
| 7505 | (let ((pos (point))) | ||
| 7506 | (backward-delete-char N) | ||
| 7507 | (skip-chars-forward "^|") | ||
| 7508 | (insert " ") | ||
| 7509 | (goto-char (1- pos))) | ||
| 7510 | (backward-delete-char N))) | ||
| 7511 | |||
| 7512 | (defun org-delete-char (N) | ||
| 7513 | "Like `delete-char', but insert whitespace at field end in tables. | ||
| 7514 | When deleting characters, in tables this function will insert whitespace in | ||
| 7515 | front of the next \"|\" separator, to keep the table aligned. The table | ||
| 7516 | will still be marked for re-alignment, because a narrow field may lead to | ||
| 7517 | a reduced column width." | ||
| 7518 | (interactive "p") | ||
| 7519 | (if (and (org-table-p) | ||
| 7520 | (eq N 1)) | ||
| 7521 | (if (looking-at ".*?|") | ||
| 7522 | (let ((pos (point))) | ||
| 7523 | (replace-match (concat | ||
| 7524 | (substring (match-string 0) 1 -1) | ||
| 7525 | " |")) | ||
| 7526 | (goto-char pos))) | ||
| 7527 | (delete-char N))) | ||
| 7528 | |||
| 7529 | ;; How to do this: Measure non-white length of current string | ||
| 7530 | ;; If equal to column width, we should realign. | ||
| 7531 | |||
| 7532 | (when (eq org-enable-table-editor 'optimized) | ||
| 7533 | ;; If the user wants maximum table support, we need to hijack | ||
| 7534 | ;; some standard editing functions | ||
| 7535 | (substitute-key-definition 'self-insert-command 'org-self-insert-command | ||
| 7536 | org-mode-map global-map) | ||
| 7537 | (substitute-key-definition 'delete-char 'org-delete-char | ||
| 7538 | org-mode-map global-map) | ||
| 7539 | (substitute-key-definition 'delete-backward-char 'org-delete-backward-char | ||
| 7540 | org-mode-map global-map) | ||
| 7541 | (define-key org-mode-map "|" 'self-insert-command)) | ||
| 7542 | |||
| 7044 | (defun org-shiftcursor-error () | 7543 | (defun org-shiftcursor-error () |
| 7045 | "Throw an error because Shift-Cursor command was applied in wrong context." | 7544 | "Throw an error because Shift-Cursor command was applied in wrong context." |
| 7046 | (error "This command is only active in tables and on headlines.")) | 7545 | (error "This command is only active in tables and on headlines.")) |
| @@ -7173,9 +7672,18 @@ the automatic table editor has been turned off." | |||
| 7173 | "Call `org-table-next-row' or `newline'." | 7672 | "Call `org-table-next-row' or `newline'." |
| 7174 | (interactive "P") | 7673 | (interactive "P") |
| 7175 | (cond | 7674 | (cond |
| 7176 | ((org-at-table-p) (org-table-next-row)) | 7675 | ((org-at-table-p) |
| 7676 | (org-table-justify-field-maybe) | ||
| 7677 | (org-table-next-row)) | ||
| 7177 | (t (newline)))) | 7678 | (t (newline)))) |
| 7178 | 7679 | ||
| 7680 | (defun org-meta-return (&optional arg) | ||
| 7681 | "Call `org-insert-heading' or `org-table-wrap-region'." | ||
| 7682 | (interactive "P") | ||
| 7683 | (cond | ||
| 7684 | ((org-at-table-p) | ||
| 7685 | (org-table-wrap-region arg)) | ||
| 7686 | (t (org-insert-heading arg)))) | ||
| 7179 | 7687 | ||
| 7180 | ;;; Menu entries | 7688 | ;;; Menu entries |
| 7181 | 7689 | ||
| @@ -7245,7 +7753,7 @@ the automatic table editor has been turned off." | |||
| 7245 | ["Check Deadlines this file" org-check-deadlines t] | 7753 | ["Check Deadlines this file" org-check-deadlines t] |
| 7246 | ["Timeline current file" org-timeline t] | 7754 | ["Timeline current file" org-timeline t] |
| 7247 | "--" | 7755 | "--" |
| 7248 | ["Adenda (multifile)" org-agenda-overview t]) | 7756 | ["Adenda (multifile)" org-agenda t]) |
| 7249 | ("File List for Agenda") | 7757 | ("File List for Agenda") |
| 7250 | "--" | 7758 | "--" |
| 7251 | ("Hyperlinks" | 7759 | ("Hyperlinks" |
| @@ -7586,6 +8094,7 @@ When ENTRY is non-nil, show the entire entry." | |||
| 7586 | 8094 | ||
| 7587 | (run-hooks 'org-load-hook) | 8095 | (run-hooks 'org-load-hook) |
| 7588 | 8096 | ||
| 8097 | ;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd | ||
| 8098 | |||
| 7589 | ;;; org.el ends here | 8099 | ;;; org.el ends here |
| 7590 | 8100 | ||
| 7591 | ;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd | ||