Mercurial > emacs
comparison lisp/textmodes/org.el @ 65654:4a2301f2a9bb
* textmodes/org.el (org-mode-map, orgtbl-mode-map): Move
keybindings with `C-c C-h' prefix to `C-c C-x' prefix. Make use
of `remap' feature when available. Additional key bindings for
better tty support.
(org-mode-restart, org-force-self-insert): New commands.
(org-time-stamp-inactive): New command.
(org-remap): New function.
(org-table-auto-blank-field, org-level-color-stars-only): New
options.
(org-enable-fixed-width-editor): Moved to `org-structure'
customization group.
(org-self-insert-command, orgtbl-self-insert-command): Modified to
blank field after field motion commands.
author | Carsten Dominik <dominik@science.uva.nl> |
---|---|
date | Fri, 23 Sep 2005 15:45:39 +0000 |
parents | e274642bf5d5 |
children | 7d20cbe1d616 ee12d75eb214 |
comparison
equal
deleted
inserted
replaced
65653:e5a39c229bf4 | 65654:4a2301f2a9bb |
---|---|
3 ;; Copyright (c) 2004, 2005 Free Software Foundation | 3 ;; Copyright (c) 2004, 2005 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.15 | 8 ;; Version: 3.16 |
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 |
78 ;; Org-mode, you can read the same text online as HTML. There is also an | 78 ;; Org-mode, you can read the same text online as HTML. There is also an |
79 ;; excellent reference card made by Philip Rooke. | 79 ;; excellent reference card made by Philip Rooke. |
80 ;; | 80 ;; |
81 ;; Changes: | 81 ;; Changes: |
82 ;; ------- | 82 ;; ------- |
83 ;; Version 3.16 | |
84 ;; - In tables, directly after the field motion commands like TAB and RET, | |
85 ;; typing a character will blank the field. Can be turned off with | |
86 ;; variable `org-table-auto-blank-field'. | |
87 ;; - Inactive timestamps with `C-c !'. These do not trigger the agenda | |
88 ;; and are not linked to the calendar. | |
89 ;; - Additional key bindings to allow Org-mode to function on a tty emacs. | |
90 ;; - `C-c C-h' prefix key replaced by `C-c C-x', and `C-c C-x C-h' replaced | |
91 ;; by `C-c C-x b' (b=Browser). This was necessary to recover the | |
92 ;; standard meaning of C-h after a prefix key (show prefix bindings). | |
93 ;; | |
83 ;; Version 3.15 | 94 ;; Version 3.15 |
84 ;; - QUOTE keyword at the beginning of an entry causes fixed-width export | 95 ;; - QUOTE keyword at the beginning of an entry causes fixed-width export |
85 ;; of unmodified entry text. `C-c :' toggles this keyword. | 96 ;; of unmodified entry text. `C-c :' toggles this keyword. |
86 ;; - New face `org-special-keyword' which is used for COMMENT, QUOTE, | 97 ;; - New face `org-special-keyword' which is used for COMMENT, QUOTE, |
87 ;; DEADLINE and SCHEDULED, and priority cookies. Default is only a weak | 98 ;; DEADLINE and SCHEDULED, and priority cookies. Default is only a weak |
197 (defvar calc-embedded-open-formula) | 208 (defvar calc-embedded-open-formula) |
198 (defvar font-lock-unfontify-region-function) | 209 (defvar font-lock-unfontify-region-function) |
199 | 210 |
200 ;;; Customization variables | 211 ;;; Customization variables |
201 | 212 |
202 (defvar org-version "3.15" | 213 (defvar org-version "3.16" |
203 "The version number of the file org.el.") | 214 "The version number of the file org.el.") |
204 (defun org-version () | 215 (defun org-version () |
205 (interactive) | 216 (interactive) |
206 (message "Org-mode version %s" org-version)) | 217 (message "Org-mode version %s" org-version)) |
207 | 218 |
841 This can be used to recenter the window to show as much of the structure | 852 This can be used to recenter the window to show as much of the structure |
842 as possible." | 853 as possible." |
843 :group 'org-structure | 854 :group 'org-structure |
844 :type 'hook) | 855 :type 'hook) |
845 | 856 |
857 (defcustom org-level-color-stars-only nil | |
858 "Non-nil means fontify only the stars in each headline. | |
859 When nil, the entire headline is fontified. | |
860 After changin this, requires restart of Emacs to become effective." | |
861 :group 'org-structure | |
862 :type 'boolean) | |
863 | |
846 (defcustom org-adapt-indentation t | 864 (defcustom org-adapt-indentation t |
847 "Non-nil means, adapt indentation when promoting and demoting. | 865 "Non-nil means, adapt indentation when promoting and demoting. |
848 When this is set and the *entire* text in an entry is indented, the | 866 When this is set and the *entire* text in an entry is indented, the |
849 indentation is increased by one space in a demotion command, and | 867 indentation is increased by one space in a demotion command, and |
850 decreased by one in a promotion command. If any line in the entry | 868 decreased by one in a promotion command. If any line in the entry |
851 body starts at column 0, indentation is not changed at all." | 869 body starts at column 0, indentation is not changed at all." |
870 :group 'org-structure | |
871 :type 'boolean) | |
872 | |
873 (defcustom org-enable-fixed-width-editor t | |
874 "Non-nil means, lines starting with \":\" are treated as fixed-width. | |
875 This currently only means, they are never auto-wrapped. | |
876 When nil, such lines will be treated like ordinary lines. | |
877 See also the QUOTE keyword." | |
852 :group 'org-structure | 878 :group 'org-structure |
853 :type 'boolean) | 879 :type 'boolean) |
854 | 880 |
855 (defcustom org-cycle-emulate-tab t | 881 (defcustom org-cycle-emulate-tab t |
856 "Where should `org-cycle' emulate TAB. | 882 "Where should `org-cycle' emulate TAB. |
1153 - Use automatic overwrite mode in front of whitespace in table fields. | 1179 - Use automatic overwrite mode in front of whitespace in table fields. |
1154 This make the structure of the table stay in tact as long as the edited | 1180 This make the structure of the table stay in tact as long as the edited |
1155 field does not exceed the column width. | 1181 field does not exceed the column width. |
1156 - Minimize the number of realigns. Normally, the table is aligned each time | 1182 - Minimize the number of realigns. Normally, the table is aligned each time |
1157 TAB or RET are pressed to move to another field. With optimization this | 1183 TAB or RET are pressed to move to another field. With optimization this |
1158 happens only if changes to a field might have changed the column width. | 1184 happens only if changes to a field might have changed the column width. |
1159 Optimization requires replacing the functions `self-insert-command', | 1185 Optimization requires replacing the functions `self-insert-command', |
1160 `delete-char', and `backward-delete-char' in Org-mode buffers, with a | 1186 `delete-char', and `backward-delete-char' in Org-mode buffers, with a |
1161 slight (in fact: unnoticeable) speed impact for normal typing. Org-mode is | 1187 slight (in fact: unnoticeable) speed impact for normal typing. Org-mode is |
1162 very good at guessing when a re-align will be necessary, but you can always | 1188 very good at guessing when a re-align will be necessary, but you can always |
1163 force one with `C-c C-c'. | 1189 force one with \\[org-ctrl-c-ctrl-c]. |
1164 | 1190 |
1165 If you would like to use the optimized version in Org-mode, but the | 1191 If you would like to use the optimized version in Org-mode, but the |
1166 un-optimized version in OrgTbl-mode, see the variable `orgtbl-optimized'. | 1192 un-optimized version in OrgTbl-mode, see the variable `orgtbl-optimized'. |
1167 | 1193 |
1168 This variable can be used to turn on and off the table editor during a session, | 1194 This variable can be used to turn on and off the table editor during a session, |
1169 but in order to toggle optimization, a restart is required." | 1195 but in order to toggle optimization, a restart is required. |
1196 | |
1197 See also the variable `org-table-auto-blank-field'." | |
1170 :group 'org-table | 1198 :group 'org-table |
1171 :type '(choice | 1199 :type '(choice |
1172 (const :tag "off" nil) | 1200 (const :tag "off" nil) |
1173 (const :tag "on" t) | 1201 (const :tag "on" t) |
1174 (const :tag "on, optimized" optimized))) | 1202 (const :tag "on, optimized" optimized))) |
1203 | |
1204 (defcustom org-table-auto-blank-field t | |
1205 "Non-nil means, automatically blank table field when starting to type into it. | |
1206 This only happens when typing immediately after a field motion | |
1207 command (TAB, S-TAB or RET). | |
1208 Only relevant when `org-enable-table-editor' is equal to `optimized'." | |
1209 :group 'org-table | |
1210 :type 'boolean) | |
1175 | 1211 |
1176 (defcustom org-table-default-size "5x2" | 1212 (defcustom org-table-default-size "5x2" |
1177 "The default size for newly created tables, Columns x Rows." | 1213 "The default size for newly created tables, Columns x Rows." |
1178 :group 'org-table | 1214 :group 'org-table |
1179 :type 'string) | 1215 :type 'string) |
1243 | 1279 |
1244 (defcustom org-table-tab-recognizes-table.el t | 1280 (defcustom org-table-tab-recognizes-table.el t |
1245 "Non-nil means, TAB will automatically notice a table.el table. | 1281 "Non-nil means, TAB will automatically notice a table.el table. |
1246 When it sees such a table, it moves point into it and - if necessary - | 1282 When it sees such a table, it moves point into it and - if necessary - |
1247 calls `table-recognize-table'." | 1283 calls `table-recognize-table'." |
1248 :group 'org-table | |
1249 :type 'boolean) | |
1250 | |
1251 ;; FIXME: Should this one be in another group? Which one? | |
1252 (defcustom org-enable-fixed-width-editor t | |
1253 "Non-nil means, lines starting with \":\" are treated as fixed-width. | |
1254 This currently only means, they are never auto-wrapped. | |
1255 When nil, such lines will be treated like ordinary lines." | |
1256 :group 'org-table | 1284 :group 'org-table |
1257 :type 'boolean) | 1285 :type 'boolean) |
1258 | 1286 |
1259 (defgroup org-table-calculation nil | 1287 (defgroup org-table-calculation nil |
1260 "Options concerning tables in Org-mode." | 1288 "Options concerning tables in Org-mode." |
1976 ))) | 2004 ))) |
1977 (set (make-local-variable 'org-font-lock-keywords) | 2005 (set (make-local-variable 'org-font-lock-keywords) |
1978 (append | 2006 (append |
1979 (if org-noutline-p ; FIXME: I am not sure if eval will work | 2007 (if org-noutline-p ; FIXME: I am not sure if eval will work |
1980 ; on XEmacs if noutline is ever ported | 2008 ; on XEmacs if noutline is ever ported |
1981 '((eval . (list "^\\(\\*+\\).*" | 2009 `((eval . (list "^\\(\\*+\\).*" |
1982 0 '(nth | 2010 ,(if org-level-color-stars-only 1 0) |
2011 '(nth ;; FIXME: 1<->0 ???? | |
1983 (% (- (match-end 1) (match-beginning 1) 1) | 2012 (% (- (match-end 1) (match-beginning 1) 1) |
1984 org-n-levels) | 2013 org-n-levels) |
1985 org-level-faces) | 2014 org-level-faces) |
1986 nil t))) | 2015 nil t))) |
1987 '(("^\\(\\(\\*+\\)[^\r\n]*\\)[\n\r]" | 2016 `(("^\\(\\(\\*+\\)[^\r\n]*\\)[\n\r]" |
1988 (1 (nth (% (- (match-end 2) (match-beginning 2) 1) | 2017 (,(if org-level-color-stars-only 2 0) |
1989 org-n-levels) | 2018 (nth (% (- (match-end 2) (match-beginning 2) 1) |
1990 org-level-faces) | 2019 org-n-levels) |
1991 nil t)))) | 2020 org-level-faces) |
2021 nil t)))) | |
1992 org-font-lock-extra-keywords)) | 2022 org-font-lock-extra-keywords)) |
1993 (set (make-local-variable 'font-lock-defaults) | 2023 (set (make-local-variable 'font-lock-defaults) |
1994 '(org-font-lock-keywords t nil nil backward-paragraph)) | 2024 '(org-font-lock-keywords t nil nil backward-paragraph)) |
1995 (kill-local-variable 'font-lock-keywords) nil)) | 2025 (kill-local-variable 'font-lock-keywords) nil)) |
1996 | 2026 |
2804 (if (and (eq type :todo) | 2834 (if (and (eq type :todo) |
2805 (assoc completion table)) | 2835 (assoc completion table)) |
2806 (insert " ")) | 2836 (insert " ")) |
2807 (if (and (equal type :opt) (assoc completion table)) | 2837 (if (and (equal type :opt) (assoc completion table)) |
2808 (message "%s" (substitute-command-keys | 2838 (message "%s" (substitute-command-keys |
2809 "Press \\[org-complete] again to insert example settings")))) | 2839 "Press \\[org-complete] again to insert example settings")))) |
2810 (t | 2840 (t |
2811 (message "Making completion list...") | 2841 (message "Making completion list...") |
2812 (let ((list (sort (all-completions pattern table) 'string<))) | 2842 (let ((list (sort (all-completions pattern table) 'string<))) |
2813 (with-output-to-temp-buffer "*Completions*" | 2843 (with-output-to-temp-buffer "*Completions*" |
2814 (display-completion-list list))) | 2844 (display-completion-list list))) |
2911 (insert | 2941 (insert |
2912 org-deadline-string " " | 2942 org-deadline-string " " |
2913 (format-time-string (car org-time-stamp-formats) | 2943 (format-time-string (car org-time-stamp-formats) |
2914 (org-read-date nil 'to-time))) | 2944 (org-read-date nil 'to-time))) |
2915 (message "%s" (substitute-command-keys | 2945 (message "%s" (substitute-command-keys |
2916 "Use \\[org-timestamp-up-day] and \\[org-timestamp-down-day] to change the date."))) | 2946 "Use \\[org-timestamp-up-day] and \\[org-timestamp-down-day] to change the date."))) |
2917 | 2947 |
2918 (defun org-schedule () | 2948 (defun org-schedule () |
2919 "Insert the SCHEDULED: string to schedule a TODO item. | 2949 "Insert the SCHEDULED: string to schedule a TODO item. |
2920 A timestamp is also inserted - use \\[org-timestamp-up] and \\[org-timestamp-down] | 2950 A timestamp is also inserted - use \\[org-timestamp-up] and \\[org-timestamp-down] |
2921 to modify it to the correct date." | 2951 to modify it to the correct date." |
2923 (insert | 2953 (insert |
2924 org-scheduled-string " " | 2954 org-scheduled-string " " |
2925 (format-time-string (car org-time-stamp-formats) | 2955 (format-time-string (car org-time-stamp-formats) |
2926 (org-read-date nil 'to-time))) | 2956 (org-read-date nil 'to-time))) |
2927 (message "%s" (substitute-command-keys | 2957 (message "%s" (substitute-command-keys |
2928 "Use \\[org-timestamp-up-day] and \\[org-timestamp-down-day] to change the date."))) | 2958 "Use \\[org-timestamp-up-day] and \\[org-timestamp-down-day] to change the date."))) |
2929 | 2959 |
2930 | 2960 |
2931 (defun org-occur (regexp &optional callback) | 2961 (defun org-occur (regexp &optional callback) |
2932 "Make a compact tree which shows all matches of REGEXP. | 2962 "Make a compact tree which shows all matches of REGEXP. |
2933 The tree will show the lines where the regexp matches, and all higher | 2963 The tree will show the lines where the regexp matches, and all higher |
3074 (t | 3104 (t |
3075 (setq time (let ((this-command this-command)) | 3105 (setq time (let ((this-command this-command)) |
3076 (org-read-date arg 'totime))) | 3106 (org-read-date arg 'totime))) |
3077 (if org-time-was-given (setq fmt (cdr org-time-stamp-formats))) | 3107 (if org-time-was-given (setq fmt (cdr org-time-stamp-formats))) |
3078 (insert (format-time-string fmt time)))))) | 3108 (insert (format-time-string fmt time)))))) |
3109 | |
3110 (defun org-time-stamp-inactive (&optional arg) | |
3111 "Insert an inactive time stamp. | |
3112 An inactive time stamp is enclosed in square brackets instead of angle | |
3113 brackets. It is inactive in the sense that it does not trigger agenda entries, | |
3114 does not link to the calendar and cannot be changed with the S-cursor keys." | |
3115 (interactive "P") | |
3116 (let ((fmt (if arg (cdr org-time-stamp-formats) | |
3117 (car org-time-stamp-formats))) | |
3118 (org-time-was-given nil) | |
3119 time) | |
3120 (setq time (org-read-date arg 'totime)) | |
3121 (if org-time-was-given (setq fmt (cdr org-time-stamp-formats))) | |
3122 (setq fmt (concat "[" (substring fmt 1 -1) "]")) | |
3123 (insert (format-time-string fmt time)))) | |
3079 | 3124 |
3080 ;;; FIXME: Make the function take "Fri" as "next friday" | 3125 ;;; FIXME: Make the function take "Fri" as "next friday" |
3081 (defun org-read-date (&optional with-time to-time) | 3126 (defun org-read-date (&optional with-time to-time) |
3082 "Read a date and make things smooth for the user. | 3127 "Read a date and make things smooth for the user. |
3083 The prompt will suggest to enter an ISO date, but you can also enter anything | 3128 The prompt will suggest to enter an ISO date, but you can also enter anything |
3537 (define-key org-agenda-mode-map "." 'org-agenda-goto-today) | 3582 (define-key org-agenda-mode-map "." 'org-agenda-goto-today) |
3538 (define-key org-agenda-mode-map "d" 'org-agenda-day-view) | 3583 (define-key org-agenda-mode-map "d" 'org-agenda-day-view) |
3539 (define-key org-agenda-mode-map "w" 'org-agenda-week-view) | 3584 (define-key org-agenda-mode-map "w" 'org-agenda-week-view) |
3540 (define-key org-agenda-mode-map (org-key 'S-right) 'org-agenda-date-later) | 3585 (define-key org-agenda-mode-map (org-key 'S-right) 'org-agenda-date-later) |
3541 (define-key org-agenda-mode-map (org-key 'S-left) 'org-agenda-date-earlier) | 3586 (define-key org-agenda-mode-map (org-key 'S-left) 'org-agenda-date-earlier) |
3587 (define-key org-agenda-mode-map [?\C-c ?\C-x (right)] 'org-agenda-date-later) | |
3588 (define-key org-agenda-mode-map [?\C-c ?\C-x (left)] 'org-agenda-date-earlier) | |
3542 | 3589 |
3543 (define-key org-agenda-mode-map ">" 'org-agenda-date-prompt) | 3590 (define-key org-agenda-mode-map ">" 'org-agenda-date-prompt) |
3544 (let ((l '(1 2 3 4 5 6 7 8 9 0))) | 3591 (let ((l '(1 2 3 4 5 6 7 8 9 0))) |
3545 (while l (define-key org-agenda-mode-map | 3592 (while l (define-key org-agenda-mode-map |
3546 (int-to-string (pop l)) 'digit-argument))) | 3593 (int-to-string (pop l)) 'digit-argument))) |
3572 (define-key org-agenda-mode-map "H" 'org-agenda-holidays) | 3619 (define-key org-agenda-mode-map "H" 'org-agenda-holidays) |
3573 (define-key org-agenda-mode-map "+" 'org-agenda-priority-up) | 3620 (define-key org-agenda-mode-map "+" 'org-agenda-priority-up) |
3574 (define-key org-agenda-mode-map "-" 'org-agenda-priority-down) | 3621 (define-key org-agenda-mode-map "-" 'org-agenda-priority-down) |
3575 (define-key org-agenda-mode-map (org-key 'S-up) 'org-agenda-priority-up) | 3622 (define-key org-agenda-mode-map (org-key 'S-up) 'org-agenda-priority-up) |
3576 (define-key org-agenda-mode-map (org-key 'S-down) 'org-agenda-priority-down) | 3623 (define-key org-agenda-mode-map (org-key 'S-down) 'org-agenda-priority-down) |
3624 (define-key org-agenda-mode-map [?\C-c ?\C-x (up)] 'org-agenda-priority-up) | |
3625 (define-key org-agenda-mode-map [?\C-c ?\C-x (down)] 'org-agenda-priority-down) | |
3577 (define-key org-agenda-mode-map [(right)] 'org-agenda-later) | 3626 (define-key org-agenda-mode-map [(right)] 'org-agenda-later) |
3578 (define-key org-agenda-mode-map [(left)] 'org-agenda-earlier) | 3627 (define-key org-agenda-mode-map [(left)] 'org-agenda-earlier) |
3579 | 3628 |
3580 (defvar org-agenda-keymap (copy-keymap org-agenda-mode-map) | 3629 (defvar org-agenda-keymap (copy-keymap org-agenda-mode-map) |
3581 "Local keymap for agenda entries from Org-mode.") | 3630 "Local keymap for agenda entries from Org-mode.") |
6319 (org-table-align)) | 6368 (org-table-align)) |
6320 (error "No non-empty field found")))) | 6369 (error "No non-empty field found")))) |
6321 | 6370 |
6322 (defun org-table-check-inside-data-field () | 6371 (defun org-table-check-inside-data-field () |
6323 "Is point inside a table data field? | 6372 "Is point inside a table data field? |
6324 I.e. not on a hline or before the first or after the last column?" | 6373 I.e. not on a hline or before the first or after the last column? |
6374 This actually throws an error, so it aborts the current command." | |
6325 (if (or (not (org-at-table-p)) | 6375 (if (or (not (org-at-table-p)) |
6326 (= (org-table-current-column) 0) | 6376 (= (org-table-current-column) 0) |
6327 (org-at-table-hline-p) | 6377 (org-at-table-hline-p) |
6328 (looking-at "[ \t]*$")) | 6378 (looking-at "[ \t]*$")) |
6329 (error "Not in table data field"))) | 6379 (error "Not in table data field"))) |
7012 m (floor (/ diff 60)) diff (mod diff 60) | 7062 m (floor (/ diff 60)) diff (mod diff 60) |
7013 s diff) | 7063 s diff) |
7014 (format "%d:%02d:%02d" h m s)))) | 7064 (format "%d:%02d:%02d" h m s)))) |
7015 (kill-new sres) | 7065 (kill-new sres) |
7016 (if (interactive-p) | 7066 (if (interactive-p) |
7017 (message "%s" | 7067 (message "s" |
7018 (concat | 7068 (substitute-command-keys |
7019 (format "Sum of %d items: %-20s " (length numbers) sres) | 7069 (format "Sum of %d items: %-20s (\\[yank] will insert result into buffer)" |
7020 (substitute-command-keys | 7070 (length numbers) sres)))) |
7021 "(\\[yank] will insert result into buffer)") | |
7022 )) | |
7023 ) | |
7024 sres)))) | 7071 sres)))) |
7025 | 7072 |
7026 (defun org-table-get-number-for-summing (s) | 7073 (defun org-table-get-number-for-summing (s) |
7027 (let (n) | 7074 (let (n) |
7028 (if (string-match "^ *|? *" s) | 7075 (if (string-match "^ *|? *" s) |
7124 (error "Abort"))) | 7171 (error "Abort"))) |
7125 (org-table-may-need-update nil) | 7172 (org-table-may-need-update nil) |
7126 (stored-list (org-table-get-stored-formulas)) | 7173 (stored-list (org-table-get-stored-formulas)) |
7127 (stored (cdr (assoc scol stored-list))) | 7174 (stored (cdr (assoc scol stored-list))) |
7128 (eq (cond | 7175 (eq (cond |
7129 ((and stored equation (string-match "^ *= *$" equation)) | 7176 ((and stored equation (string-match "^ *=? *$" equation)) |
7130 stored) | 7177 stored) |
7131 ((stringp equation) | 7178 ((stringp equation) |
7132 equation) | 7179 equation) |
7133 (t (read-string | 7180 (t (read-string |
7134 (format "%s formula $%s=" (if named "Field" "Column") scol) | 7181 (format "%s formula $%s=" (if named "Field" "Column") scol) |
7292 ;; We already know we are in a table. Get field will only return a formula | 7339 ;; We already know we are in a table. Get field will only return a formula |
7293 ;; when appropriate. It might return a separator line, but no problem. | 7340 ;; when appropriate. It might return a separator line, but no problem. |
7294 (when org-table-formula-evaluate-inline | 7341 (when org-table-formula-evaluate-inline |
7295 (let* ((field (org-trim (or (org-table-get-field) ""))) | 7342 (let* ((field (org-trim (or (org-table-get-field) ""))) |
7296 named eq) | 7343 named eq) |
7297 (when (string-match "^:?=\\(.+\\)" field) | 7344 (when (string-match "^:?=\\(.*\\)" field) |
7298 (setq named (equal (string-to-char field) ?:) | 7345 (setq named (equal (string-to-char field) ?:) |
7299 eq (match-string 1 field)) | 7346 eq (match-string 1 field)) |
7300 (if (fboundp 'calc-eval) | 7347 (if (fboundp 'calc-eval) |
7301 (org-table-eval-formula (if named '(4) nil) eq)))))) | 7348 (org-table-eval-formula (if named '(4) nil) eq)))))) |
7302 | 7349 |
7914 '([(meta down)] org-table-move-row-down) | 7961 '([(meta down)] org-table-move-row-down) |
7915 '("\C-c\C-w" org-table-cut-region) | 7962 '("\C-c\C-w" org-table-cut-region) |
7916 '("\C-c\M-w" org-table-copy-region) | 7963 '("\C-c\M-w" org-table-copy-region) |
7917 '("\C-c\C-y" org-table-paste-rectangle) | 7964 '("\C-c\C-y" org-table-paste-rectangle) |
7918 '("\C-c-" org-table-insert-hline) | 7965 '("\C-c-" org-table-insert-hline) |
7919 '([(shift tab)] org-table-previous-field) | 7966 ; '([(shift tab)] org-table-previous-field) |
7920 '("\C-c\C-c" org-ctrl-c-ctrl-c) | |
7921 '("\C-m" org-table-next-row) | 7967 '("\C-m" org-table-next-row) |
7922 (list (org-key 'S-return) 'org-table-copy-down) | 7968 (list (org-key 'S-return) 'org-table-copy-down) |
7923 '([(meta return)] org-table-wrap-region) | 7969 '([(meta return)] org-table-wrap-region) |
7924 '("\C-c\C-q" org-table-wrap-region) | 7970 '("\C-c\C-q" org-table-wrap-region) |
7925 '("\C-c?" org-table-current-column) | 7971 '("\C-c?" org-table-current-column) |
7944 (orgtbl-make-binding 'orgtbl-ret 101 "\C-m" [(return)])) | 7990 (orgtbl-make-binding 'orgtbl-ret 101 "\C-m" [(return)])) |
7945 (define-key orgtbl-mode-map [(tab)] | 7991 (define-key orgtbl-mode-map [(tab)] |
7946 (orgtbl-make-binding 'orgtbl-tab 102 [(tab)] "\C-i")) | 7992 (orgtbl-make-binding 'orgtbl-tab 102 [(tab)] "\C-i")) |
7947 (define-key orgtbl-mode-map "\C-i" | 7993 (define-key orgtbl-mode-map "\C-i" |
7948 (orgtbl-make-binding 'orgtbl-tab 103 "\C-i" [(tab)]))) | 7994 (orgtbl-make-binding 'orgtbl-tab 103 "\C-i" [(tab)]))) |
7995 (define-key orgtbl-mode-map "\C-i" | |
7996 (orgtbl-make-binding 'orgtbl-tab 104 [(shift tab)])) | |
7997 (define-key orgtbl-mode-map "\C-c\C-c" | |
7998 (orgtbl-make-binding 'org-ctrl-c-ctrl-c 105 "\C-c\C-c")) | |
7949 (when orgtbl-optimized | 7999 (when orgtbl-optimized |
7950 ;; If the user wants maximum table support, we need to hijack | 8000 ;; If the user wants maximum table support, we need to hijack |
7951 ;; some standard editing functions | 8001 ;; some standard editing functions |
7952 (substitute-key-definition 'self-insert-command 'orgtbl-self-insert-command | 8002 (org-remap orgtbl-mode-map |
7953 orgtbl-mode-map global-map) | 8003 'self-insert-command 'orgtbl-self-insert-command |
7954 (substitute-key-definition 'delete-char 'orgtbl-delete-char | 8004 'delete-char 'orgtbl-delete-char |
7955 orgtbl-mode-map global-map) | 8005 'delete-backward-char 'orgtbl-delete-backward-char) |
7956 (substitute-key-definition 'delete-backward-char 'orgtbl-delete-backward-char | 8006 (define-key orgtbl-mode-map "|" 'org-force-self-insert)) |
7957 orgtbl-mode-map global-map) | |
7958 (define-key org-mode-map "|" 'self-insert-command)) | |
7959 (easy-menu-define orgtbl-mode-menu orgtbl-mode-map "OrgTbl menu" | 8007 (easy-menu-define orgtbl-mode-menu orgtbl-mode-map "OrgTbl menu" |
7960 '("OrgTbl" | 8008 '("OrgTbl" |
7961 ["Align" org-ctrl-c-ctrl-c :active (org-at-table-p) :keys "C-c C-c"] | 8009 ["Align" org-ctrl-c-ctrl-c :active (org-at-table-p) :keys "C-c C-c"] |
7962 ["Next Field" org-cycle :active (org-at-table-p) :keys "TAB"] | 8010 ["Next Field" org-cycle :active (org-at-table-p) :keys "TAB"] |
7963 ["Previous Field" org-shifttab :active (org-at-table-p) :keys "S-TAB"] | 8011 ["Previous Field" org-shifttab :active (org-at-table-p) :keys "S-TAB"] |
7978 ["Delete Row" org-shiftmetaup :active (org-at-table-p) :keys "M-S-<up>"] | 8026 ["Delete Row" org-shiftmetaup :active (org-at-table-p) :keys "M-S-<up>"] |
7979 ["Insert Row" org-shiftmetadown :active (org-at-table-p) :keys "M-S-<down>"] | 8027 ["Insert Row" org-shiftmetadown :active (org-at-table-p) :keys "M-S-<down>"] |
7980 "--" | 8028 "--" |
7981 ["Insert Hline" org-table-insert-hline :active (org-at-table-p) :keys "C-c -"]) | 8029 ["Insert Hline" org-table-insert-hline :active (org-at-table-p) :keys "C-c -"]) |
7982 ("Rectangle" | 8030 ("Rectangle" |
7983 ["Copy Rectangle" org-copy-special :active (org-at-table-p) :keys "C-c M-w"] | 8031 ["Copy Rectangle" org-copy-special :active (org-at-table-p) :keys "C-c C-x M-w"] |
7984 ["Cut Rectangle" org-cut-special :active (org-at-table-p) :keys "C-c C-w"] | 8032 ["Cut Rectangle" org-cut-special :active (org-at-table-p) :keys "C-c C-x C-w"] |
7985 ["Paste Rectangle" org-paste-special :active (org-at-table-p) :keys "C-c C-y"] | 8033 ["Paste Rectangle" org-paste-special :active (org-at-table-p) :keys "C-c C-x C-y"] |
7986 ["Fill Rectangle" org-table-wrap-region :active (org-at-table-p) :keys "C-c C-q"]) | 8034 ["Fill Rectangle" org-table-wrap-region :active (org-at-table-p) :keys "C-c C-q"]) |
7987 "--" | 8035 "--" |
7988 ["Set Column Formula" org-table-eval-formula :active (org-at-table-p) :keys "C-c ="] | 8036 ["Set Column Formula" org-table-eval-formula :active (org-at-table-p) :keys "C-c ="] |
7989 ["Set Named Field Formula" (org-table-eval-formula '(4)) :active (org-at-table-p) :keys "C-u C-c ="] | 8037 ["Set Named Field Formula" (org-table-eval-formula '(4)) :active (org-at-table-p) :keys "C-u C-c ="] |
7990 ["Edit Formulas" org-table-edit-formulas :active (org-at-table-p) :keys "C-c '"] | 8038 ["Edit Formulas" org-table-edit-formulas :active (org-at-table-p) :keys "C-c '"] |
8016 "Like `self-insert-command', use overwrite-mode for whitespace in tables. | 8064 "Like `self-insert-command', use overwrite-mode for whitespace in tables. |
8017 If the cursor is in a table looking at whitespace, the whitespace is | 8065 If the cursor is in a table looking at whitespace, the whitespace is |
8018 overwritten, and the table is not marked as requiring realignment." | 8066 overwritten, and the table is not marked as requiring realignment." |
8019 (interactive "p") | 8067 (interactive "p") |
8020 (if (and (org-at-table-p) | 8068 (if (and (org-at-table-p) |
8069 (or | |
8070 (and org-table-auto-blank-field | |
8071 (member last-command | |
8072 '(orgtbl-hijacker-command-100 | |
8073 orgtbl-hijacker-command-101 | |
8074 orgtbl-hijacker-command-102 | |
8075 orgtbl-hijacker-command-103 | |
8076 orgtbl-hijacker-command-104 | |
8077 orgtbl-hijacker-command-105)) | |
8078 (org-table-blank-field)) | |
8079 t) | |
8021 (eq N 1) | 8080 (eq N 1) |
8022 (looking-at "[^|\n]* +|")) | 8081 (looking-at "[^|\n]* +|")) |
8023 (let (org-table-may-need-update) | 8082 (let (org-table-may-need-update) |
8024 (goto-char (1- (match-end 0))) | 8083 (goto-char (1- (match-end 0))) |
8025 (delete-backward-char 1) | 8084 (delete-backward-char 1) |
8026 (goto-char (match-beginning 0)) | 8085 (goto-char (match-beginning 0)) |
8027 (self-insert-command N)) | 8086 (self-insert-command N)) |
8028 (setq org-table-may-need-update t) | 8087 (setq org-table-may-need-update t) |
8029 (let (orgtbl-mode) | 8088 (let (orgtbl-mode) |
8030 (call-interactively (key-binding (vector last-input-event)))))) | 8089 (call-interactively (key-binding (vector last-input-event)))))) |
8090 | |
8091 (defun org-force-self-insert (N) | |
8092 "Needed to enforce self-insert under remapping." | |
8093 (interactive "p") | |
8094 (self-insert-command N)) | |
8031 | 8095 |
8032 (defun orgtbl-delete-backward-char (N) | 8096 (defun orgtbl-delete-backward-char (N) |
8033 "Like `delete-backward-char', insert whitespace at field end in tables. | 8097 "Like `delete-backward-char', insert whitespace at field end in tables. |
8034 When deleting backwards, in tables this function will insert whitespace in | 8098 When deleting backwards, in tables this function will insert whitespace in |
8035 front of the next \"|\" separator, to keep the table aligned. The table will | 8099 front of the next \"|\" separator, to keep the table aligned. The table will |
9342 ;; abcd fgh j lmnopqrstuvwxyz ? #$ -+*/= [] ; |,.<>~ \t necessary bindings | 9406 ;; abcd fgh j lmnopqrstuvwxyz ? #$ -+*/= [] ; |,.<>~ \t necessary bindings |
9343 ;; e (?) useful from outline-mode | 9407 ;; e (?) useful from outline-mode |
9344 ;; i k @ expendable from outline-mode | 9408 ;; i k @ expendable from outline-mode |
9345 ;; 0123456789 ! %^& ()_{} " `' free | 9409 ;; 0123456789 ! %^& ()_{} " `' free |
9346 | 9410 |
9347 (define-key org-mode-map "\C-i" 'org-cycle) | 9411 ;; TAB key with modifiers |
9412 (define-key org-mode-map "\C-i" 'org-cycle) | |
9348 (define-key org-mode-map [(meta tab)] 'org-complete) | 9413 (define-key org-mode-map [(meta tab)] 'org-complete) |
9349 (define-key org-mode-map "\M-\C-i" 'org-complete) | 9414 (define-key org-mode-map "\M-\C-i" 'org-complete) ; for tty emacs |
9350 (define-key org-mode-map [(meta shift left)] 'org-shiftmetaleft) | 9415 ;; The following line is necessary under Suse GNU/Linux |
9351 (define-key org-mode-map [(meta left)] 'org-metaleft) | 9416 (unless org-xemacs-p |
9352 (define-key org-mode-map [(meta shift right)] 'org-shiftmetaright) | 9417 (define-key org-mode-map [S-iso-lefttab] 'org-shifttab)) |
9353 (define-key org-mode-map [(meta shift up)] 'org-shiftmetaup) | 9418 (define-key org-mode-map [(shift tab)] 'org-shifttab) |
9354 (define-key org-mode-map [(meta shift down)] 'org-shiftmetadown) | 9419 |
9420 (define-key org-mode-map (org-key 'S-return) 'org-table-copy-down) | |
9421 (define-key org-mode-map "\C-c\C-xc" 'org-table-copy-down) ; tty | |
9422 (define-key org-mode-map [(meta shift return)] 'org-insert-todo-heading) | |
9423 (define-key org-mode-map "\C-c\C-xM" 'org-insert-todo-heading) ; tty | |
9424 (define-key org-mode-map [(meta return)] 'org-meta-return) | |
9425 (define-key org-mode-map "\C-c\C-xm" 'org-meta-return) ; tty emacs | |
9426 (define-key org-mode-map [?\e (return)] 'org-meta-return) ; tty emacs | |
9427 | |
9428 ;; Cursor keys with modifiers | |
9429 (define-key org-mode-map [(meta left)] 'org-metaleft) | |
9430 (define-key org-mode-map [?\e (left)] 'org-metaleft) ; for tty emacs | |
9431 (define-key org-mode-map "\C-c\C-xl" 'org-metaleft) ; for tty emacs | |
9355 (define-key org-mode-map [(meta right)] 'org-metaright) | 9432 (define-key org-mode-map [(meta right)] 'org-metaright) |
9356 (define-key org-mode-map [(meta up)] 'org-metaup) | 9433 (define-key org-mode-map [?\e (right)] 'org-metaright) ; for tty emacs |
9357 (define-key org-mode-map [(meta down)] 'org-metadown) | 9434 (define-key org-mode-map "\C-c\C-xr" 'org-metaright) ; for tty emacs |
9358 ;(define-key org-mode-map "\C-c\C-h\C-w" 'org-cut-subtree) | 9435 (define-key org-mode-map [(meta up)] 'org-metaup) |
9359 ;(define-key org-mode-map "\C-c\C-h\M-w" 'org-copy-subtree) | 9436 (define-key org-mode-map [?\e (up)] 'org-metaup) ; for tty emacs |
9360 ;(define-key org-mode-map "\C-c\C-h\C-y" 'org-paste-subtree) | 9437 (define-key org-mode-map "\C-c\C-xu" 'org-metaup) ; for tty emacs |
9361 (define-key org-mode-map "\C-c\C-h\C-w" 'org-cut-special) | 9438 (define-key org-mode-map [(meta down)] 'org-metadown) |
9362 (define-key org-mode-map "\C-c\C-h\M-w" 'org-copy-special) | 9439 (define-key org-mode-map [?\e (down)] 'org-metadown) ; for tty emacs |
9363 (define-key org-mode-map "\C-c\C-h\C-y" 'org-paste-special) | 9440 (define-key org-mode-map "\C-c\C-xd" 'org-metadown) ; for tty emacs |
9441 | |
9442 (define-key org-mode-map [(meta shift left)] 'org-shiftmetaleft) | |
9443 (define-key org-mode-map "\C-c\C-xL" 'org-shiftmetaleft) ; tty | |
9444 (define-key org-mode-map [(meta shift right)] 'org-shiftmetaright) | |
9445 (define-key org-mode-map "\C-c\C-xR" 'org-shiftmetaright) ; tty | |
9446 (define-key org-mode-map [(meta shift up)] 'org-shiftmetaup) | |
9447 (define-key org-mode-map "\C-c\C-xU" 'org-shiftmetaup) ; tty | |
9448 (define-key org-mode-map [(meta shift down)] 'org-shiftmetadown) | |
9449 (define-key org-mode-map "\C-c\C-xD" 'org-shiftmetadown) ; tty | |
9450 (define-key org-mode-map (org-key 'S-up) 'org-shiftup) | |
9451 (define-key org-mode-map [?\C-c ?\C-x (up)] 'org-shiftup) | |
9452 (define-key org-mode-map (org-key 'S-down) 'org-shiftdown) | |
9453 (define-key org-mode-map [?\C-c ?\C-x (down)] 'org-shiftdown) | |
9454 (define-key org-mode-map (org-key 'S-left) 'org-timestamp-down-day) | |
9455 (define-key org-mode-map [?\C-c ?\C-x (left)] 'org-timestamp-down-day) | |
9456 (define-key org-mode-map (org-key 'S-right) 'org-timestamp-up-day) | |
9457 (define-key org-mode-map [?\C-c ?\C-x (right)] 'org-timestamp-up-day) | |
9458 | |
9459 ;; All the other keys | |
9364 (define-key org-mode-map "\C-c$" 'org-archive-subtree) | 9460 (define-key org-mode-map "\C-c$" 'org-archive-subtree) |
9365 (define-key org-mode-map "\C-c\C-j" 'org-goto) | 9461 (define-key org-mode-map "\C-c\C-j" 'org-goto) |
9366 (define-key org-mode-map "\C-c\C-t" 'org-todo) | 9462 (define-key org-mode-map "\C-c\C-t" 'org-todo) |
9367 (define-key org-mode-map "\C-c\C-s" 'org-schedule) | 9463 (define-key org-mode-map "\C-c\C-s" 'org-schedule) |
9368 (define-key org-mode-map "\C-c\C-d" 'org-deadline) | 9464 (define-key org-mode-map "\C-c\C-d" 'org-deadline) |
9370 (define-key org-mode-map "\C-c\C-v" 'org-show-todo-tree) | 9466 (define-key org-mode-map "\C-c\C-v" 'org-show-todo-tree) |
9371 (define-key org-mode-map "\C-c\C-w" 'org-check-deadlines) | 9467 (define-key org-mode-map "\C-c\C-w" 'org-check-deadlines) |
9372 (define-key org-mode-map "\C-c/" 'org-occur) ; Minor-mode reserved | 9468 (define-key org-mode-map "\C-c/" 'org-occur) ; Minor-mode reserved |
9373 (define-key org-mode-map "\C-c\C-m" 'org-insert-heading) | 9469 (define-key org-mode-map "\C-c\C-m" 'org-insert-heading) |
9374 (define-key org-mode-map "\M-\C-m" 'org-insert-heading) | 9470 (define-key org-mode-map "\M-\C-m" 'org-insert-heading) |
9375 (define-key org-mode-map [(meta shift return)] 'org-insert-todo-heading) | |
9376 (define-key org-mode-map "\C-c\C-l" 'org-insert-link) | 9471 (define-key org-mode-map "\C-c\C-l" 'org-insert-link) |
9377 (define-key org-mode-map "\C-c\C-o" 'org-open-at-point) | 9472 (define-key org-mode-map "\C-c\C-o" 'org-open-at-point) |
9378 (define-key org-mode-map "\C-c\C-z" 'org-time-stamp) ; Alternative binding | 9473 (define-key org-mode-map "\C-c\C-z" 'org-time-stamp) ; Alternative binding |
9379 (define-key org-mode-map "\C-c." 'org-time-stamp) ; Minor-mode reserved | 9474 (define-key org-mode-map "\C-c." 'org-time-stamp) ; Minor-mode reserved |
9475 (define-key org-mode-map "\C-c!" 'org-time-stamp-inactive) ; Minor-mode r. | |
9380 (define-key org-mode-map "\C-c," 'org-priority) ; Minor-mode reserved | 9476 (define-key org-mode-map "\C-c," 'org-priority) ; Minor-mode reserved |
9381 (define-key org-mode-map "\C-c\C-y" 'org-evaluate-time-range) | 9477 (define-key org-mode-map "\C-c\C-y" 'org-evaluate-time-range) |
9382 (define-key org-mode-map "\C-c>" 'org-goto-calendar) | 9478 (define-key org-mode-map "\C-c>" 'org-goto-calendar) |
9383 (define-key org-mode-map "\C-c<" 'org-date-from-calendar) | 9479 (define-key org-mode-map "\C-c<" 'org-date-from-calendar) |
9384 (define-key org-mode-map "\C-c[" 'org-add-file) | 9480 (define-key org-mode-map "\C-c[" 'org-add-file) |
9385 (define-key org-mode-map "\C-c]" 'org-remove-file) | 9481 (define-key org-mode-map "\C-c]" 'org-remove-file) |
9386 (define-key org-mode-map "\C-c\C-r" 'org-timeline) | 9482 (define-key org-mode-map "\C-c\C-r" 'org-timeline) |
9387 (define-key org-mode-map (org-key 'S-up) 'org-shiftup) | |
9388 (define-key org-mode-map (org-key 'S-down) 'org-shiftdown) | |
9389 (define-key org-mode-map (org-key 'S-left) 'org-timestamp-down-day) | |
9390 (define-key org-mode-map (org-key 'S-right) 'org-timestamp-up-day) | |
9391 (define-key org-mode-map "\C-c-" 'org-table-insert-hline) | 9483 (define-key org-mode-map "\C-c-" 'org-table-insert-hline) |
9392 ;; The following line is necessary for German keyboards under Suse GNU/Linux | |
9393 (unless org-xemacs-p | |
9394 (define-key org-mode-map [S-iso-lefttab] 'org-shifttab)) | |
9395 (define-key org-mode-map [(shift tab)] 'org-shifttab) | |
9396 (define-key org-mode-map "\C-c\C-c" 'org-ctrl-c-ctrl-c) | 9484 (define-key org-mode-map "\C-c\C-c" 'org-ctrl-c-ctrl-c) |
9397 (define-key org-mode-map "\C-m" 'org-return) | 9485 (define-key org-mode-map "\C-m" 'org-return) |
9398 (define-key org-mode-map (org-key 'S-return) 'org-table-copy-down) | |
9399 (define-key org-mode-map [(meta return)] 'org-meta-return) | |
9400 (define-key org-mode-map "\C-c?" 'org-table-current-column) | 9486 (define-key org-mode-map "\C-c?" 'org-table-current-column) |
9401 (define-key org-mode-map "\C-c " 'org-table-blank-field) | 9487 (define-key org-mode-map "\C-c " 'org-table-blank-field) |
9402 (define-key org-mode-map "\C-c+" 'org-table-sum) | 9488 (define-key org-mode-map "\C-c+" 'org-table-sum) |
9403 (define-key org-mode-map "\C-c|" 'org-table-toggle-vline-visibility) | 9489 (define-key org-mode-map "\C-c|" 'org-table-toggle-vline-visibility) |
9404 (define-key org-mode-map "\C-c=" 'org-table-eval-formula) | 9490 (define-key org-mode-map "\C-c=" 'org-table-eval-formula) |
9409 (define-key org-mode-map "\C-c\C-q" 'org-table-wrap-region) | 9495 (define-key org-mode-map "\C-c\C-q" 'org-table-wrap-region) |
9410 (define-key org-mode-map "\C-c\C-xa" 'org-export-as-ascii) | 9496 (define-key org-mode-map "\C-c\C-xa" 'org-export-as-ascii) |
9411 (define-key org-mode-map "\C-c\C-x\C-a" 'org-export-as-ascii) | 9497 (define-key org-mode-map "\C-c\C-x\C-a" 'org-export-as-ascii) |
9412 (define-key org-mode-map "\C-c\C-xv" 'org-export-copy-visible) | 9498 (define-key org-mode-map "\C-c\C-xv" 'org-export-copy-visible) |
9413 (define-key org-mode-map "\C-c\C-x\C-v" 'org-export-copy-visible) | 9499 (define-key org-mode-map "\C-c\C-x\C-v" 'org-export-copy-visible) |
9500 ;; OPML support is only planned | |
9414 ;(define-key org-mode-map "\C-c\C-xo" 'org-export-as-opml) | 9501 ;(define-key org-mode-map "\C-c\C-xo" 'org-export-as-opml) |
9415 ;(define-key org-mode-map "\C-c\C-x\C-o" 'org-export-as-opml) | 9502 ;(define-key org-mode-map "\C-c\C-x\C-o" 'org-export-as-opml) |
9416 (define-key org-mode-map "\C-c\C-xt" 'org-insert-export-options-template) | 9503 (define-key org-mode-map "\C-c\C-xt" 'org-insert-export-options-template) |
9417 (define-key org-mode-map "\C-c:" 'org-toggle-fixed-width-section) | 9504 (define-key org-mode-map "\C-c:" 'org-toggle-fixed-width-section) |
9418 (define-key org-mode-map "\C-c\C-xh" 'org-export-as-html) | 9505 (define-key org-mode-map "\C-c\C-xh" 'org-export-as-html) |
9419 (define-key org-mode-map "\C-c\C-x\C-h" 'org-export-as-html-and-open) | 9506 (define-key org-mode-map "\C-c\C-xb" 'org-export-as-html-and-open) |
9507 (define-key org-mode-map "\C-c\C-x\C-b" 'org-export-as-html-and-open) | |
9508 | |
9509 (define-key org-mode-map "\C-c\C-x\C-w" 'org-cut-special) | |
9510 (define-key org-mode-map "\C-c\C-x\M-w" 'org-copy-special) | |
9511 (define-key org-mode-map "\C-c\C-x\C-y" 'org-paste-special) | |
9420 | 9512 |
9421 (defsubst org-table-p () (org-at-table-p)) | 9513 (defsubst org-table-p () (org-at-table-p)) |
9422 | 9514 |
9423 (defun org-self-insert-command (N) | 9515 (defun org-self-insert-command (N) |
9424 "Like `self-insert-command', use overwrite-mode for whitespace in tables. | 9516 "Like `self-insert-command', use overwrite-mode for whitespace in tables. |
9425 If the cursor is in a table looking at whitespace, the whitespace is | 9517 If the cursor is in a table looking at whitespace, the whitespace is |
9426 overwritten, and the table is not marked as requiring realignment." | 9518 overwritten, and the table is not marked as requiring realignment." |
9427 (interactive "p") | 9519 (interactive "p") |
9428 (if (and (org-table-p) | 9520 (if (and (org-table-p) |
9521 (or | |
9522 (and org-table-auto-blank-field | |
9523 (member last-command | |
9524 '(org-cycle org-return org-shifttab org-ctrl-c-ctrl-c)) | |
9525 (org-table-blank-field)) | |
9526 t) | |
9429 (eq N 1) | 9527 (eq N 1) |
9430 (looking-at "[^|\n]* +|")) | 9528 (looking-at "[^|\n]* +|")) |
9431 (let (org-table-may-need-update) | 9529 (let (org-table-may-need-update) |
9432 (goto-char (1- (match-end 0))) | 9530 (goto-char (1- (match-end 0))) |
9433 (delete-backward-char 1) | 9531 (delete-backward-char 1) |
9478 (delete-char N))) | 9576 (delete-char N))) |
9479 | 9577 |
9480 ;; How to do this: Measure non-white length of current string | 9578 ;; How to do this: Measure non-white length of current string |
9481 ;; If equal to column width, we should realign. | 9579 ;; If equal to column width, we should realign. |
9482 | 9580 |
9581 (defun org-remap (map &rest commands) | |
9582 "In MAP, remap the functions given in COMMANDS. | |
9583 COMMANDS is a list of alternating OLDDEF NEWDEF command names." | |
9584 (let (new old) | |
9585 (while commands | |
9586 (setq old (pop commands) new (pop commands)) | |
9587 (if (fboundp 'command-remapping) | |
9588 (define-key map (vector 'remap old) new) | |
9589 (substitute-key-definition old new map global-map))))) | |
9590 | |
9483 (when (eq org-enable-table-editor 'optimized) | 9591 (when (eq org-enable-table-editor 'optimized) |
9484 ;; If the user wants maximum table support, we need to hijack | 9592 ;; If the user wants maximum table support, we need to hijack |
9485 ;; some standard editing functions | 9593 ;; some standard editing functions |
9486 (substitute-key-definition 'self-insert-command 'org-self-insert-command | 9594 (org-remap org-mode-map |
9487 org-mode-map global-map) | 9595 'self-insert-command 'org-self-insert-command |
9488 (substitute-key-definition 'delete-char 'org-delete-char | 9596 'delete-char 'org-delete-char |
9489 org-mode-map global-map) | 9597 'delete-backward-char 'org-delete-backward-char) |
9490 (substitute-key-definition 'delete-backward-char 'org-delete-backward-char | 9598 (define-key org-mode-map "|" 'org-force-self-insert)) |
9491 org-mode-map global-map) | |
9492 (define-key org-mode-map "|" 'self-insert-command)) | |
9493 | 9599 |
9494 (defun org-shiftcursor-error () | 9600 (defun org-shiftcursor-error () |
9495 "Throw an error because Shift-Cursor command was applied in wrong context." | 9601 "Throw an error because Shift-Cursor command was applied in wrong context." |
9496 (error "This command is only active in tables and on headlines")) | 9602 (error "This command is only active in tables and on headlines")) |
9497 | 9603 |
9498 (defun org-shifttab () | 9604 (defun org-shifttab () |
9499 "Call `(org-cycle t)' or `org-table-previous-field'." | 9605 "Global visibility cycling or move to previous table field. |
9606 Calls `(org-cycle t)' or `org-table-previous-field', depending on context. | |
9607 See the individual commands for more information." | |
9500 (interactive) | 9608 (interactive) |
9501 (cond | 9609 (cond |
9502 ((org-at-table-p) (org-table-previous-field)) | 9610 ((org-at-table-p) (org-table-previous-field)) |
9503 (t (org-cycle '(4))))) | 9611 (t (org-cycle '(4))))) |
9504 | 9612 |
9505 (defun org-shiftmetaleft () | 9613 (defun org-shiftmetaleft () |
9506 "Call `org-promote-subtree' or `org-table-delete-column'." | 9614 "Promote subtree or delete table column. |
9615 Calls `org-promote-subtree' or `org-table-delete-column', depending on context. | |
9616 See the individual commands for more information." | |
9507 (interactive) | 9617 (interactive) |
9508 (cond | 9618 (cond |
9509 ((org-at-table-p) (org-table-delete-column)) | 9619 ((org-at-table-p) (org-table-delete-column)) |
9510 ((org-on-heading-p) (org-promote-subtree)) | 9620 ((org-on-heading-p) (org-promote-subtree)) |
9511 (t (org-shiftcursor-error)))) | 9621 (t (org-shiftcursor-error)))) |
9512 | 9622 |
9513 (defun org-shiftmetaright () | 9623 (defun org-shiftmetaright () |
9514 "Call `org-demote-subtree' or `org-table-insert-column'." | 9624 "Demote subtree or insert table column. |
9625 Calls `org-demote-subtree' or `org-table-insert-column', depending on context. | |
9626 See the individual commands for more information." | |
9515 (interactive) | 9627 (interactive) |
9516 (cond | 9628 (cond |
9517 ((org-at-table-p) (org-table-insert-column)) | 9629 ((org-at-table-p) (org-table-insert-column)) |
9518 ((org-on-heading-p) (org-demote-subtree)) | 9630 ((org-on-heading-p) (org-demote-subtree)) |
9519 (t (org-shiftcursor-error)))) | 9631 (t (org-shiftcursor-error)))) |
9520 | 9632 |
9521 (defun org-shiftmetaup (&optional arg) | 9633 (defun org-shiftmetaup (&optional arg) |
9522 "Call `org-move-subtree-up' or `org-table-kill-row'." | 9634 "Move subtree up or kill table row. |
9635 Calls `org-move-subtree-up' or `org-table-kill-row', depending on context. | |
9636 See the individual commands for more information." | |
9523 (interactive "P") | 9637 (interactive "P") |
9524 (cond | 9638 (cond |
9525 ((org-at-table-p) (org-table-kill-row)) | 9639 ((org-at-table-p) (org-table-kill-row)) |
9526 ((org-on-heading-p) (org-move-subtree-up arg)) | 9640 ((org-on-heading-p) (org-move-subtree-up arg)) |
9527 (t (org-shiftcursor-error)))) | 9641 (t (org-shiftcursor-error)))) |
9528 (defun org-shiftmetadown (&optional arg) | 9642 (defun org-shiftmetadown (&optional arg) |
9529 "Call `org-move-subtree-down' or `org-table-insert-row'." | 9643 "Move subtree down or insert table row. |
9644 Calls `org-move-subtree-down' or `org-table-insert-row', depending on context. | |
9645 See the individual commands for more information." | |
9530 (interactive "P") | 9646 (interactive "P") |
9531 (cond | 9647 (cond |
9532 ((org-at-table-p) (org-table-insert-row arg)) | 9648 ((org-at-table-p) (org-table-insert-row arg)) |
9533 ((org-on-heading-p) (org-move-subtree-down arg)) | 9649 ((org-on-heading-p) (org-move-subtree-down arg)) |
9534 (t (org-shiftcursor-error)))) | 9650 (t (org-shiftcursor-error)))) |
9535 | 9651 |
9536 (defun org-metaleft (&optional arg) | 9652 (defun org-metaleft (&optional arg) |
9537 "Call `org-do-promote' or `org-table-move-column' to left." | 9653 "Promote heading or move table column to left. |
9654 Calls `org-do-promote' or `org-table-move-column', depending on context. | |
9655 See the individual commands for more information." | |
9538 (interactive "P") | 9656 (interactive "P") |
9539 (cond | 9657 (cond |
9540 ((org-at-table-p) (org-table-move-column 'left)) | 9658 ((org-at-table-p) (org-table-move-column 'left)) |
9541 ((or (org-on-heading-p) (org-region-active-p)) (org-do-promote)) | 9659 ((or (org-on-heading-p) (org-region-active-p)) (org-do-promote)) |
9542 (t (backward-word (prefix-numeric-value arg))))) | 9660 (t (backward-word (prefix-numeric-value arg))))) |
9543 | 9661 |
9544 (defun org-metaright (&optional arg) | 9662 (defun org-metaright (&optional arg) |
9545 "Call `org-do-demote' or `org-table-move-column' to right." | 9663 "Demote subtree or move table column to right. |
9664 Calls `org-do-demote' or `org-table-move-column', depending on context. | |
9665 See the individual commands for more information." | |
9546 (interactive "P") | 9666 (interactive "P") |
9547 (cond | 9667 (cond |
9548 ((org-at-table-p) (org-table-move-column nil)) | 9668 ((org-at-table-p) (org-table-move-column nil)) |
9549 ((or (org-on-heading-p) (org-region-active-p)) (org-do-demote)) | 9669 ((or (org-on-heading-p) (org-region-active-p)) (org-do-demote)) |
9550 (t (forward-word (prefix-numeric-value arg))))) | 9670 (t (forward-word (prefix-numeric-value arg))))) |
9551 | 9671 |
9552 (defun org-metaup (&optional arg) | 9672 (defun org-metaup (&optional arg) |
9553 "Call `org-move-subtree-up' or `org-table-move-row' up." | 9673 "Move subtree up or move table row up. |
9674 Calls `org-move-subtree-up' or `org-table-move-row', depending on context. | |
9675 See the individual commands for more information." | |
9554 (interactive "P") | 9676 (interactive "P") |
9555 (cond | 9677 (cond |
9556 ((org-at-table-p) (org-table-move-row 'up)) | 9678 ((org-at-table-p) (org-table-move-row 'up)) |
9557 ((org-on-heading-p) (org-move-subtree-up arg)) | 9679 ((org-on-heading-p) (org-move-subtree-up arg)) |
9558 (t (org-shiftcursor-error)))) | 9680 (t (org-shiftcursor-error)))) |
9559 | 9681 |
9560 (defun org-metadown (&optional arg) | 9682 (defun org-metadown (&optional arg) |
9561 "Call `org-move-subtree-down' or `org-table-move-row' down." | 9683 "Move subtree down or move table row down. |
9684 Calls `org-move-subtree-down' or `org-table-move-row', depending on context. | |
9685 See the individual commands for more information." | |
9562 (interactive "P") | 9686 (interactive "P") |
9563 (cond | 9687 (cond |
9564 ((org-at-table-p) (org-table-move-row nil)) | 9688 ((org-at-table-p) (org-table-move-row nil)) |
9565 ((org-on-heading-p) (org-move-subtree-down arg)) | 9689 ((org-on-heading-p) (org-move-subtree-down arg)) |
9566 (t (org-shiftcursor-error)))) | 9690 (t (org-shiftcursor-error)))) |
9567 | 9691 |
9568 (defun org-shiftup (&optional arg) | 9692 (defun org-shiftup (&optional arg) |
9569 "Call `org-timestamp-up' or `org-priority-up'." | 9693 "Increase item in timestamp or increase priority of current item. |
9694 Calls `org-timestamp-up' or `org-priority-up', depending on context. | |
9695 See the individual commands for more information." | |
9570 (interactive "P") | 9696 (interactive "P") |
9571 (cond | 9697 (cond |
9572 ((org-at-timestamp-p) (org-timestamp-up arg)) | 9698 ((org-at-timestamp-p) (org-timestamp-up arg)) |
9573 (t (org-priority-up)))) | 9699 (t (org-priority-up)))) |
9574 | 9700 |
9575 (defun org-shiftdown (&optional arg) | 9701 (defun org-shiftdown (&optional arg) |
9576 "Call `org-timestamp-down' or `org-priority-down'." | 9702 "Decrease item in timestamp or decrease priority of current item. |
9703 Calls `org-timestamp-down' or `org-priority-down', depending on context. | |
9704 See the individual commands for more information." | |
9577 (interactive "P") | 9705 (interactive "P") |
9578 (cond | 9706 (cond |
9579 ((org-at-timestamp-p) (org-timestamp-down arg)) | 9707 ((org-at-timestamp-p) (org-timestamp-down arg)) |
9580 (t (org-priority-down)))) | 9708 (t (org-priority-down)))) |
9581 | 9709 |
9582 (defun org-copy-special () | 9710 (defun org-copy-special () |
9583 "Call either `org-table-copy' or `org-copy-subtree'." | 9711 "Copy region in table or copy current subtree. |
9712 Calls `org-table-copy' or `org-copy-subtree', depending on context. | |
9713 See the individual commands for more information." | |
9584 (interactive) | 9714 (interactive) |
9585 (call-interactively | 9715 (call-interactively |
9586 (if (org-at-table-p) 'org-table-copy-region 'org-copy-subtree))) | 9716 (if (org-at-table-p) 'org-table-copy-region 'org-copy-subtree))) |
9587 | 9717 |
9588 (defun org-cut-special () | 9718 (defun org-cut-special () |
9589 "Call either `org-table-copy' or `org-cut-subtree'." | 9719 "Cut region in table or cut current subtree. |
9720 Calls `org-table-copy' or `org-cut-subtree', depending on context. | |
9721 See the individual commands for more information." | |
9590 (interactive) | 9722 (interactive) |
9591 (call-interactively | 9723 (call-interactively |
9592 (if (org-at-table-p) 'org-table-cut-region 'org-cut-subtree))) | 9724 (if (org-at-table-p) 'org-table-cut-region 'org-cut-subtree))) |
9593 | 9725 |
9594 (defun org-paste-special (arg) | 9726 (defun org-paste-special (arg) |
9595 "Call either `org-table-paste-rectangle' or `org-paste-subtree'." | 9727 "Paste rectangular region into table, or past subtree relative to level. |
9728 Calls `org-table-paste-rectangle' or `org-paste-subtree', depending on context. | |
9729 See the individual commands for more information." | |
9596 (interactive "P") | 9730 (interactive "P") |
9597 (if (org-at-table-p) | 9731 (if (org-at-table-p) |
9598 (org-table-paste-rectangle) | 9732 (org-table-paste-rectangle) |
9599 (org-paste-subtree arg))) | 9733 (org-paste-subtree arg))) |
9600 | 9734 |
9603 When the cursor is inside a table created by the table.el package, | 9737 When the cursor is inside a table created by the table.el package, |
9604 activate that table. Otherwise, if the cursor is at a normal table | 9738 activate that table. Otherwise, if the cursor is at a normal table |
9605 created with org.el, re-align that table. This command works even if | 9739 created with org.el, re-align that table. This command works even if |
9606 the automatic table editor has been turned off. | 9740 the automatic table editor has been turned off. |
9607 If the cursor is in one of the special #+KEYWORD lines, this triggers | 9741 If the cursor is in one of the special #+KEYWORD lines, this triggers |
9608 scanning the buffer for these lines and updating the information." | 9742 scanning the buffer for these lines and updating the information. |
9743 If the cursor is on a #+TBLFM line, re-apply the formulae to the table." | |
9609 (interactive "P") | 9744 (interactive "P") |
9610 (let ((org-enable-table-editor t)) | 9745 (let ((org-enable-table-editor t)) |
9611 (cond | 9746 (cond |
9612 ((org-at-table.el-p) | 9747 ((org-at-table.el-p) |
9613 (require 'table) | 9748 (require 'table) |
9627 (save-excursion | 9762 (save-excursion |
9628 (beginning-of-line 1) | 9763 (beginning-of-line 1) |
9629 (skip-chars-backward " \r\n\t") | 9764 (skip-chars-backward " \r\n\t") |
9630 (if (org-at-table-p) (org-table-recalculate t)))) | 9765 (if (org-at-table-p) (org-table-recalculate t)))) |
9631 (t | 9766 (t |
9632 (let ((org-inhibit-startup t)) (org-mode))))) | 9767 (org-mode-restart)))) |
9633 ((org-region-active-p) | 9768 ((org-region-active-p) |
9634 (org-table-convert-region (region-beginning) (region-end) arg)) | 9769 (org-table-convert-region (region-beginning) (region-end) arg)) |
9635 ((and (region-beginning) (region-end)) | 9770 ((and (region-beginning) (region-end)) |
9636 (if (y-or-n-p "Convert inactive region to table? ") | 9771 (if (y-or-n-p "Convert inactive region to table? ") |
9637 (org-table-convert-region (region-beginning) (region-end) arg) | 9772 (org-table-convert-region (region-beginning) (region-end) arg) |
9638 (error "Abort"))) | 9773 (error "Abort"))) |
9639 (t (error "No table at point, and no region to make one"))))) | 9774 (t (error "No table at point, and no region to make one"))))) |
9640 | 9775 |
9776 (defun org-mode-restart () | |
9777 "Restart Org-mode, to scan again for special lines. | |
9778 Also updates the keyword regular expressions." | |
9779 (interactive) | |
9780 (let ((org-inhibit-startup t)) (org-mode)) | |
9781 (message "Org-mode restarted to refresh keyword and special line setup")) | |
9782 | |
9641 (defun org-return () | 9783 (defun org-return () |
9642 "Call `org-table-next-row' or `newline'." | 9784 "Goto next table row or insert a newline. |
9785 Calls `org-table-next-row' or `newline', depending on context. | |
9786 See the individual commands for more information." | |
9643 (interactive) | 9787 (interactive) |
9644 (cond | 9788 (cond |
9645 ((org-at-table-p) | 9789 ((org-at-table-p) |
9646 (org-table-justify-field-maybe) | 9790 (org-table-justify-field-maybe) |
9647 (org-table-next-row)) | 9791 (org-table-next-row)) |
9648 (t (newline)))) | 9792 (t (newline)))) |
9649 | 9793 |
9650 (defun org-meta-return (&optional arg) | 9794 (defun org-meta-return (&optional arg) |
9651 "Call `org-insert-heading' or `org-table-wrap-region'." | 9795 "Insert a new heading or wrap a region in a table. |
9796 Calls `org-insert-heading' or `org-table-wrap-region', depending on context. | |
9797 See the individual commands for more information." | |
9652 (interactive "P") | 9798 (interactive "P") |
9653 (cond | 9799 (cond |
9654 ((org-at-table-p) | 9800 ((org-at-table-p) |
9655 (org-table-wrap-region arg)) | 9801 (org-table-wrap-region arg)) |
9656 (t (org-insert-heading)))) | 9802 (t (org-insert-heading)))) |
9714 ["Create/Convert from/to table.el" org-table-create-with-table.el t])) | 9860 ["Create/Convert from/to table.el" org-table-create-with-table.el t])) |
9715 | 9861 |
9716 (easy-menu-define org-org-menu org-mode-map "Org menu" | 9862 (easy-menu-define org-org-menu org-mode-map "Org menu" |
9717 '("Org" | 9863 '("Org" |
9718 ["Cycle Visibility" org-cycle (or (bobp) (outline-on-heading-p))] | 9864 ["Cycle Visibility" org-cycle (or (bobp) (outline-on-heading-p))] |
9865 ["Cycle Global Visibility" org-shifttab (not (org-at-table-p))] | |
9719 ["Sparse Tree" org-occur t] | 9866 ["Sparse Tree" org-occur t] |
9720 ["Show All" show-all t] | 9867 ["Show All" show-all t] |
9721 "--" | 9868 "--" |
9722 ["New Heading" org-insert-heading t] | 9869 ["New Heading" org-insert-heading t] |
9723 ("Navigate Headings" | 9870 ("Navigate Headings" |
9750 ["Set Priority" org-priority t] | 9897 ["Set Priority" org-priority t] |
9751 ["Priority Up" org-shiftup t] | 9898 ["Priority Up" org-shiftup t] |
9752 ["Priority Down" org-shiftdown t]) | 9899 ["Priority Down" org-shiftdown t]) |
9753 ("Dates and Scheduling" | 9900 ("Dates and Scheduling" |
9754 ["Timestamp" org-time-stamp t] | 9901 ["Timestamp" org-time-stamp t] |
9902 ["Timestamp (inactive)" org-time-stamp-inactive t] | |
9755 ("Change Date" | 9903 ("Change Date" |
9756 ["1 Day Later" org-timestamp-up-day t] | 9904 ["1 Day Later" org-timestamp-up-day t] |
9757 ["1 Day Earlier" org-timestamp-down-day t] | 9905 ["1 Day Earlier" org-timestamp-down-day t] |
9758 ["1 ... Later" org-shiftup t] | 9906 ["1 ... Later" org-shiftup t] |
9759 ["1 ... Earlier" org-shiftdown t]) | 9907 ["1 ... Earlier" org-shiftdown t]) |
9793 ("Customize" | 9941 ("Customize" |
9794 ["Browse Org Group" org-customize t] | 9942 ["Browse Org Group" org-customize t] |
9795 "--" | 9943 "--" |
9796 ["Build Full Customize Menu" org-create-customize-menu | 9944 ["Build Full Customize Menu" org-create-customize-menu |
9797 (fboundp 'customize-menu-create)]) | 9945 (fboundp 'customize-menu-create)]) |
9946 "--" | |
9947 ["Refresh setup" org-mode-restart t] | |
9798 )) | 9948 )) |
9799 | 9949 |
9800 (defun org-info (&optional node) | 9950 (defun org-info (&optional node) |
9801 "Read documentation for Org-mode in the info system. | 9951 "Read documentation for Org-mode in the info system. |
9802 With optional NODE, go directly to that node." | 9952 With optional NODE, go directly to that node." |