org.el 312 KB
 Richard M. Stallman committed Dec 06, 2004 1 ;; org.el --- Outline-based notes management and organizer  Carsten Dominik committed Jan 14, 2005 2 ;; Carstens outline-mode for keeping track of everything.  Carsten Dominik committed Jan 14, 2005 3 4 ;; Copyright (c) 2003, 2004 Free Software Foundation  Richard M. Stallman committed Dec 06, 2004 5 6 7 ;; Author: Carsten Dominik ;; Keywords: outlines, hypermedia, calendar ;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/  Carsten Dominik committed Jan 14, 2005 8 9 ;; Version: 3.04  Richard M. Stallman committed Dec 06, 2004 10 ;; This file is part of GNU Emacs.  Carsten Dominik committed Jan 14, 2005 11   Richard M. Stallman committed Dec 06, 2004 12 13 14 ;; GNU Emacs is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2, or (at your option)  Richard M. Stallman committed Dec 06, 2004 15 16 ;; any later version.  Richard M. Stallman committed Dec 06, 2004 17 18 19 20 ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details.  Richard M. Stallman committed Dec 06, 2004 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59  ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;;; Commentary: ;; ;; Org-mode is a mode for keeping notes, maintaining ToDo lists, and doing ;; project planning with a fast and effective plain-text system. ;; ;; Org-mode develops organizational tasks around a NOTES file that contains ;; information about projects as plain text. Org-mode is implemented on ;; top of outline-mode - ideal to keep the content of large files well ;; structured. It supports ToDo items, deadlines and time stamps, which ;; magically appear in the diary listing of the Emacs calendar. Tables are ;; easily created with a built-in table editor. Plain text URL-like links ;; connect to websites, emails (VM,RMAIL,WANDERLUST), Usenet messages (Gnus), ;; BBDB entries, and any files related to the projects. For printing and ;; sharing of notes, an Org-mode file (or a part of it) can be exported as ;; a structured ASCII file, or as HTML. ;; ;; Installation ;; ------------ ;; The instruction below assume that you have downloaded Org-mode from the ;; web. If Org-mode is part of the Emacs distribution or an XEmacs package, ;; you only need to add to .emacs the last three lines of Lisp code listed ;; below, i.e. the auto-mode-alist' modification and the global key bindings. ;; ;; Byte-compile org.el and put it on your load path. Then copy the ;; following lines into .emacs. The last two lines define *global* ;; keys for the commands org-store-link' and org-agenda' - please ;; choose suitable keys yourself. ;; ;; (autoload 'org-mode "org" "Org mode" t) ;; (autoload 'org-diary "org" "Diary entries from Org mode") ;; (autoload 'org-agenda "org" "Multi-file agenda from Org mode" t) ;; (autoload 'org-store-link "org" "Store a link to the current location" t)  Carsten Dominik committed Jan 14, 2005 60 61 ;; (autoload 'orgtbl-mode "org" "Org tables as a minor mode" t) ;; (autoload 'turn-on-orgtbl "org" "Org tables as a minor mode")  Richard M. Stallman committed Dec 06, 2004 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 ;; (add-to-list 'auto-mode-alist '("\\.org" . org-mode)) ;; (define-key global-map "\C-cl" 'org-store-link) ;; (define-key global-map "\C-ca" 'org-agenda) ;; ;; This will put all files with extension ".org" into Org-mode. As an ;; alternative, make the first line of a file look like this: ;; ;; MY PROJECTS -*- mode: org; -*- ;; ;; which will select Org-mode for this buffer no matter what the file's ;; name is. ;; ;; Documentation ;; ------------- ;; The documentation of Org-mode can be found in the TeXInfo file. ;; This distribution also contains a PDF version of it. At the homepage ;; of Org-mode, you can find and read online the same text as HTML. ;; ;; Changes: ;; -------  Carsten Dominik committed Jan 14, 2005 82 83 84 85 86 87 88 89 90 ;; Version 3.04 ;; - Table editor optimized to need fewer realignments, and to keep ;; table shape when typing in fields. ;; - A new minor mode, orgtbl-mode, introduces the Org-mode table editor ;; into arbitrary major modes. ;; - Fixed bug with realignment in XEmacs. ;; - Startup options can be set with special #+STARTUP line. ;; - Heading following a match in org-occur can be suppressed. ;;  Richard M. Stallman committed Dec 06, 2004 91 92 ;; Version 3.03 ;; - Copyright transfer to the FSF.  Carsten Dominik committed Jan 14, 2005 93 ;; - Effect of C-u and C-u C-u in org-timeline swapped.  Richard M. Stallman committed Dec 06, 2004 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 ;; - Timeline now always contains today, and .' jumps to it. ;; - Table editor: ;; - cut and paste of regtangular regions in tables ;; - command to convert org-mode table to table.el table and back ;; - command to treat several cells like a paragraph and fill it ;; - command to convert a buffer region to a table ;; - import/export tables as tab-separated files (exchange with Excel) ;; - Agenda: ;; - Sorting mechanism for agenda items rewritten from scratch. ;; - Sorting fully configurable. ;; - Entries specifying a time are sorted together. ;; - Completion also covers option keywords after #-'. ;; - Bug fixes. ;; ;; Version 3.01 ;; - New reference card, thanks to Philip Rooke for creating it. ;; - Single file agenda renamed to "Timeline". It no longer shows ;; warnings about upcoming deadlines/overdue scheduled items. ;; That functionality is now limited to the (multifile) agenda. ;; - When reading a date, the calendar can be manipulated with keys. ;; - Link support for RMAIL and Wanderlust (from planner.el, untested) ;; - Minor bug fixes and documentation improvements. ;; ;; Version 3.00 ;; - Multifile Agenda shows current entries from many different files. ;; - TeXInfo documentation (thanks to Christian Egli for the conversion). ;; - Additional applications for TODO keywords, see documentation. ;; Different files may have different TODO keywords etc. ;; - Priorities for TODO items. ;; - The browser mode used by org-remember-handler' is improved. ;; - Images get inlined in HTML export (thanks to Carsten Wimmer). ;; - File links can contain line numbers, like file:/usr/etc/config:255 ;; - Minor bug fixes. ;; ;; Version 2.10 ;; - TODO entries can have additional states besides TODO and DONE. ;; See new variable org-todo-keywords'. ;; - TODO keywords can be interpreted as categories. See variable ;; org-todo-interpretation'. ;; - M-TAB completion on TODO keywords, TeX symbols, and normal words. ;; - All keywords (like TODO, DEADLINE etc) are configurable. ;; - Cursor positioning optimized after pro/demotion and TODO cycling. ;; - Emphasizing in HTML works now for *bold*, /italic/ and _underline_. ;; - New commands to kill, copy and yank entire subtrees. Yanking ;; modifies the level of the tree before insertion. ;; - New command org-goto' (C-c C-j) to quickly move to other locations ;; in the buffer without affecting outline visibility. ;; - Hooks for John Wiegley's remember.el. ;; - org-read-date' pops up calendar for date selection with the mouse. ;; See variable org-popup-calendar-for-date-prompt'. ;; ;; Version 2.6 ;; - TODO items can be SCHEDULED to a certain date. ;; - Expired DEADLINEs are ignored if in an entry marked DONE. ;; - From the diary or time-sorted view (C-c C-r), C-c C-t can be used to ;; change the TODO state of an item remotely. ;; - Horizontal computations in table editor. See org-table-eval-formula'. ;; - Fixed bug with summing tables (command org-table-sum', C-c +'). ;; - Calendar window follows the timestamp when a timestamp is changed. ;; New variable org-calendar-follow-timestamp-change'. ;; - Time-sorted view (org-diary-view', C-c C-r) now uses the prefix ;; argument to force inclusion of unscheduled TODO items. ;; - New variable org-confirm-shell-links' to turn of safety query. ;; - New variable org-open-non-existing-files'. ;; ;; Version 2.4 ;; - A time-sorted view on all time stamps can be created with C-c C-r. ;; - Timestamps and Deadlines can be shown in the Emacs diary. ;; - Date ranges introduced. ;; - Time-string formats are no longer configurable. ;; - Vertical lines in tables can be made invisible with C-c |'. ;; - New "link" type to execute shell commands, like "shell:ls *.org" ;; - Upon export, "myfile.org" becomes "myfile.html" or "myfile.txt", ;; instead of "myfile.org.html" or "myfile.org.txt". ;; - When the cursor is in the white space at the beginning of a line, ;; TAB removes the whitespace before indenting again. ;; ;; Version 2.0 ;; - Windows (NT/2000) support. ;; - Works with both Emacs and XEmacs. ;; - Fully automatic table editor. ;; - New link types into Gnus, VM and BBDB. ;; - Other link system changes ;; - Time stamps are treated as links to the calendar. ;; - Easy creation of links with global command org-store-link'. ;; - Insertion of links with C-c C-l' works differently now. ;; - Space characters allowed as part of a link. ;; - Options in org-file-apps' extended. The command may now be ;; symbol 'emacs', or a lisp form. ;; Please re-read the manual section about links. ;; - Timestamp changes ;; - org-deadline' now prompts for a date. ;; - A line can now contain several timestamps. Updating of a ;; timestamp only happens if the cursor is at the timestamp. ;; - Changed the time-stamp-format to ISO, to make sure it will ;; always work (non-English month names had caused problems ;; with parse-time-string'.). Changing the time stamp format ;; is not recommended. ;; - Picture mode enhancements have been removed from org.el ;; ;; Version 1.4 ;; - Some option name changes, not backward compatible. ;; - ASCII exporter upgrade: Table of contents. ;; - HTML exporter upgrade: fixed-width regions, better ;; sub/superscripts, many TeX symbols supported. ;; - Calendar support. ;; ;; Version 1.3 ;; - HTML exporter upgrade, in particular table of contents ;; ;; Version 1.0 ;; - Initial release ;;; Code: (eval-when-compile (require 'cl)) (require 'outline) (require 'time-date) (require 'easymenu) ;;; Customization variables  Carsten Dominik committed Jan 14, 2005 216 (defvar org-version "3.04"  Richard M. Stallman committed Dec 06, 2004 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413  "The version number of the file org.el.") (defun org-version (arg) (interactive "P") (message "Org-mode version %s" org-version)) ;; The following two constants are for compatibility with different ;; Emacs versions (Emacs versus XEmacs) and with different versions of ;; outline.el. All the compatibility code in org.el is based on these two ;; constants. (defconst org-xemacs-p (featurep 'xemacs) "Are we running xemacs?") (defconst org-noutline-p (featurep 'noutline) "Are we using the new outline mode?") (defgroup org nil "Outline-based notes management and organizer " :tag "Org" :group 'outlines :group 'hypermedia :group 'calendar) (defgroup org-startup nil "Options concerning startup of Org-mode." :tag "Org Startup" :group 'org) (defcustom org-startup-folded t "Non-nil means, entering Org-mode will switch to OVERVIEW." :group 'org-startup :type 'boolean) (defcustom org-startup-truncated t "Non-nil means, entering Org-mode will set truncate-lines'. This is useful since some lines containing links can be very long and uninteresting. Also tables look terrible when wrapped." :group 'org-startup :type 'boolean) (defcustom org-startup-with-deadline-check nil "Non-nil means, entering Org-mode will run the deadline check. This means, if you start editing an org file, you will get an immediate reminder of any due deadlines." :group 'org-startup :type 'boolean) (defcustom org-insert-mode-line-in-empty-file t "Non-nil means insert the first line setting Org-mode in empty files. When the function org-mode' is called interactively in an empty, this normally means that the file name does not automatically trigger Org-mode. To ensure that the file will always be in Org-mode in the future, a line enforcing Org-mode can be inserted into the buffer." :group 'org-startup :type 'boolean) (defgroup org-keywords nil "Options concerning TODO items in Org-mode." :tag "Org Keywords" :group 'org) (defcustom org-todo-keywords '("TODO" "DONE") "List of TODO entry keywords.\\ By default, this is '(\"TODO\" \"DONE\"). The last entry in the list is considered to mean that the entry is \"done\". All the other mean that action is required, and will make the entry show up in todo lists, diaries etc. The command \org-todo] cycles an entry through these states, and an additional state where no keyword is present. For details about this cycling, see also the variable org-todo-interpretation' Changes become only effective after restarting Emacs." :group 'org-keywords :type '(repeat (string :tag "Keyword"))) (defcustom org-todo-interpretation 'sequence "Controls how TODO keywords are interpreted.\\ Possible values are sequence' and type'. This variable is only relevant if org-todo-keywords' contains more than two states. There are two ways how these keywords can be used: - As a sequence in the process of working on a TODO item, for example (setq org-todo-keywords '(\"TODO\" \"STARTED\" \"VERIFY\" \"DONE\") org-todo-interpretation 'sequence) - As different types of TODO items, for example (setq org-todo-keywords '(\"URGENT\" \"RELAXED\" \"REMIND\" \"FOR_TOM\" \"DONE\") org-todo-interpretation 'type) When the states are interpreted as a sequence, \\[org-todo] always cycles to the next state, in order to walk through all different states. So with \\[org-todo], you turn an empty entry into the state TODO. When you started working on the item, you use \\[org-todo] again to switch it to \"STARTED\", later to VERIFY and finally to DONE. When the states are interpreted as types, \\[org-todo] still cycles through when it is called several times in direct succession, in order to initially select the type. However, if not called immediately after a previous \\[org-todo], it switches from each type directly to DONE. So with the above example, you could use \\[org-todo] \\[org-todo]' to label an entry RELAXED. If you later return to this entry and press \\[org-todo] again, RELAXED will not be changed REMIND, but directly to DONE. You can create a large number of types. To initially select a type, it is then best to use C-u \\[org-todo] in order to specify the type with completion. Of course, you can also type the keyword directly into the buffer. M-TAB completes TODO keywords at the beginning of a headline." :group 'org-keywords :type '(choice (const sequence) (const type))) (defcustom org-default-priority ?B "The default priority of TODO items. This is the priority an item get if no explicit priority is given." :group 'org-keywords :type 'character) (defcustom org-lowest-priority ?C "The lowest priority of TODO items. A character like ?A, ?B etc." :group 'org-keywords :type 'character) (defcustom org-deadline-string "DEADLINE:" "String to mark deadline entries. A deadline is this string, followed by a time stamp. Should be a word, terminated by a colon. You can insert a schedule keyword and a timestamp with \\[org-deadline]. Changes become only effective after restarting Emacs." :group 'org-keywords :type 'string) (defcustom org-scheduled-string "SCHEDULED:" "String to mark scheduled TODO entries. A schedule is this string, followed by a time stamp. Should be a word, terminated by a colon. You can insert a schedule keyword and a timestamp with \\[org-schedule]. Changes become only effective after restarting Emacs." :group 'org-keywords :type 'string) (defcustom org-comment-string "COMMENT" "Entries starting with this keyword will never be exported. An entry can be toggled between COMMENT and normal with \\[org-toggle-comment]. Changes become only effective after restarting Emacs." :group 'org-keywords :type 'string) (defcustom org-after-todo-state-change-hook nil "Hook which is run after the state of a TODO item was changed. The new state (a string with a todo keyword, or nil) is available in the lisp variable state'." :group 'org-keywords :type 'hook) ;; Variables for pre-computed regular expressions, all buffer local (defvar org-todo-kwd-priority-p nil "Do TODO items have priorities?") (make-variable-buffer-local 'org-todo-kwd-priority-p) (defvar org-todo-kwd-max-priority nil "Maximum priority of TODO items") (make-variable-buffer-local 'org-todo-kwd-max-priority) (defvar org-ds-keyword-length 12 "Maximum length of the Deadline and SCHEDULED keywords.") (make-variable-buffer-local 'org-ds-keyword-length) (defvar org-done-string nil "The last string in org-todo-keywords', indicating an item is DONE.") (make-variable-buffer-local 'org-done-string) (defvar org-todo-regexp nil "Matches any of the TODO state keywords.") (make-variable-buffer-local 'org-todo-regexp) (defvar org-not-done-regexp nil "Matches any of the TODO state keywords except the last one.") (make-variable-buffer-local 'org-not-done-regexp) (defvar org-todo-line-regexp nil "Matches a headline and puts TODO state into group 2 if present.") (make-variable-buffer-local 'org-todo-line-regexp) (defvar orb-nl-done-regexp nil "Matches newline followed by a headline with the DONE keyword.") (make-variable-buffer-local 'orb-nl-done-regexp) (defvar org-looking-at-done-regexp nil "Matches the DONE keyword a point.") (make-variable-buffer-local 'org-looking-at-done-regexp) (defvar org-deadline-regexp nil "Matches the DEADLINE keyword.") (make-variable-buffer-local 'org-deadline-regexp) (defvar org-deadline-time-regexp nil "Matches the DEADLINE keyword together with a time stamp.") (make-variable-buffer-local 'org-deadline-time-regexp) (defvar org-deadline-line-regexp nil "Matches the DEADLINE keyword and the rest of the line.") (make-variable-buffer-local 'org-deadline-line-regexp) (defvar org-scheduled-regexp nil "Matches the SCHEDULED keyword.") (make-variable-buffer-local 'org-scheduled-regexp) (defvar org-scheduled-time-regexp nil "Matches the SCHEDULED keyword together with a time stamp.") (make-variable-buffer-local 'org-scheduled-time-regexp)  Carsten Dominik committed Jan 14, 2005 414 (defun org-set-regexps-and-options ()  Richard M. Stallman committed Dec 06, 2004 415 416 417  "Precompute regular expressions for current buffer." (when (eq major-mode 'org-mode) (let ((re (org-make-options-regexp  Carsten Dominik committed Jan 14, 2005 418  '("CATEGORY" "SEQ_TODO" "PRI_TODO" "TYP_TODO" "STARTUP")))  Richard M. Stallman committed Dec 06, 2004 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437  (splitre "[ \t]+") kwds int key value cat) (save-restriction (save-excursion (widen) (goto-char (point-min)) (while (re-search-forward re nil t) (setq key (match-string 1) value (match-string 2)) (cond ((equal key "CATEGORY") (setq cat (intern (car (org-split-string value splitre))))) ((equal key "SEQ_TODO") (setq int 'sequence kwds (append kwds (org-split-string value splitre)))) ((equal key "PRI_TODO") (setq int 'priority kwds (append kwds (org-split-string value splitre)))) ((equal key "TYP_TODO") (setq int 'type  Carsten Dominik committed Jan 14, 2005 438 439 440 441 442 443 444 445 446 447 448  kwds (append kwds (org-split-string value splitre)))) ((equal key "STARTUP") (let ((opts (org-split-string value splitre)) (set '(("fold" org-startup-folded t) ("nofold" org-startup-folded nil) ("dlcheck" org-startup-with-deadline-check t) ("nodlcheck" org-startup-with-deadline-check nil))) l var val) (while (setq l (assoc (pop opts) set)) (setq var (nth 1 l) val (nth 2 l)) (set (make-local-variable var) val)))))  Richard M. Stallman committed Dec 06, 2004 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559  ))) (and cat (set (make-local-variable 'org-category) cat)) (and kwds (set (make-local-variable 'org-todo-keywords) kwds)) (and int (set (make-local-variable 'org-todo-interpretation) int))) ;; Compute the regular expressions and other local variables (setq org-todo-kwd-priority-p (equal org-todo-interpretation 'priority) org-todo-kwd-max-priority (1- (length org-todo-keywords)) org-ds-keyword-length (+ 2 (max (length org-deadline-string) (length org-scheduled-string))) org-done-string (nth (1- (length org-todo-keywords)) org-todo-keywords) org-todo-regexp (concat "\\<\$$" (mapconcat 'regexp-quote org-todo-keywords "\\|") "\$$\\>") org-not-done-regexp (concat "\\<\$$" (mapconcat 'regexp-quote (nreverse (cdr (reverse org-todo-keywords))) "\\|") "\$$\\>") org-todo-line-regexp (concat "^\$$\\*+\$$[ \t]*\$$" (mapconcat 'regexp-quote org-todo-keywords "\\|") "\$$? *\$$.*\$$") orb-nl-done-regexp (concat "[\r\n]\\*+[ \t]+" org-done-string "\\>") org-looking-at-done-regexp (concat "^" org-done-string "\\>") org-deadline-regexp (concat "\\<" org-deadline-string) org-deadline-time-regexp (concat "\\<" org-deadline-string " *<\$$[^>]+\$$>") org-deadline-line-regexp (concat "\\<\$$" org-deadline-string "\$$.*") org-scheduled-regexp (concat "\\<" org-scheduled-string) org-scheduled-time-regexp (concat "\\<" org-scheduled-string " *<\$$[^>]+\$$>")) (org-set-font-lock-defaults))) (defgroup org-time nil "Options concerning time stamps and deadlines in Org-mode." :tag "Org Time" :group 'org) (defcustom org-deadline-warning-days 30 "No. of days before expiration during which a deadline becomes active. This variable governs the display in the org file." :group 'org-time :type 'number) (defcustom org-popup-calendar-for-date-prompt t "Non-nil means, pop up a calendar when prompting for a date. In the calendar, the date can be selected with mouse-1. However, the minibuffer will also be active, and you can simply enter the date as well. When nil, only the minibuffer will be available." :group 'org-time :type 'number) (defcustom org-calendar-follow-timestamp-change t "Non-nil means, make the calendar window follow timestamp changes. When a timestamp is modified and the calendar window is visible, it will be moved to the new date." :group 'org-time :type 'boolean) (defgroup org-agenda nil "Options concerning agenda display Org-mode." :tag "Org Agenda" :group 'org) (defcustom org-agenda-files nil "A list of org files for agenda/diary display. Entries are added to this list with \\[org-add-file] and removed with \\[org-remove-file]. You can also use customize to edit the list." :group 'org-agenda :type '(repeat file)) (defcustom org-select-timeline-window t "Non-nil means, after creating a timeline, move cursor into Timeline window. When nil, cursor will remain in the current window." :group 'org-agenda :type 'boolean) (defcustom org-select-agenda-window t "Non-nil means, after creating an agenda, move cursor into Agenda window. When nil, cursor will remain in the current window." :group 'org-agenda :type 'boolean) (defcustom org-agenda-show-all-dates t "Non-nil means, org-agenda' shows every day in the selected range. When nil, only the days which actually have entries are shown." :group 'org-agenda :type 'boolean) ;; FIXME: First day of month works only for current month because it would ;; require a variable ndays treatment. (defcustom org-agenda-start-on-weekday 1 "Non-nil means, start the overview always on the specified weekday. 0 Denotes Sunday, 1 denotes Monday etc. When nil, always start on the current day." :group 'org-agenda :type '(choice (const :tag "Today" nil) (const :tag "First day of month" t) (number :tag "Weekday No."))) (defcustom org-agenda-ndays 7 "Number of days to include in overview display." :group 'org-agenda :type 'number) (defcustom org-agenda-include-all-todo t  Carsten Dominik committed Jan 14, 2005 560  "Non-nil means, the multifile agenda will always contain all TODO entries.  Richard M. Stallman committed Dec 06, 2004 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 When nil, date-less entries will only be shown if org-agenda' is called with a prefix argument. When non-nil, the TODO entries will be listed at the top of the agenda, before the entries for specific days." :group 'org-agenda :type 'boolean) (defcustom org-agenda-include-diary nil "Non-nil means, when preparing the agenda, also get the entries from the emacs calendars diary." :group 'org-agenda :type 'boolean) (defcustom org-agenda-sorting-strategy '(time-up category-keep priority-down) "Sorting structure for the agenda items of a single day. This is a list of symbols which will be used in sequence to determine if an entry should be listed before another entry. The following symbols are recognized. time-up Put entries with time-of-day indications first, early first time-down Put entries with time-of-day indications first, late first category-keep Keep the default order of categories, corresponding to the sequence in org-agenda-files'. category-up Sort alphabetically by category, A-Z. category-down Sort alphabetically by category, Z-A. priority-up Sort numerically by priority, high priority last. priority-down Sort numerically by priority, high priority first. The different possibilities will be tried in sequence, and testing stops if one comparison returns a \"not-equal\". For example, the default '(time-up category-keep priority-down) means: Pull out all entries having a specified time of day and sort them, in order to make a time schedule for the current day the first thing in the agenda listing for the day. Of the entries without a time indication, keep the grouped in categories, don't sort the categories, but keep them in the sequence given in org-agenda-files'. Within each category sort by priority. Leaving out the category-keep' would mean that items will be sorted across categories by priority." :group 'org-agenda :type '(repeat (choice (const time-up) (const time-down) (const category-keep) (const category-up) (const category-down) (const priority-up) (const priority-down)))) (defcustom org-sort-agenda-notime-is-late t "Non-nil means, items without time are considered late. This is only relevant for sorting. When t, items which have no explicit time like 15:30 will be considered as 24:01, i.e. later than any items which do have a time. When nil, the default time is before 0:00." :group 'org-agenda :type 'boolean) (defvar org-category nil "Variable used by org files to set a category for agenda display. Such files should use a file variable to set it, for example -*- mode: org; org-category: \"ELisp\" If the file does not specify a category, the file's base name is used instead.") (defgroup org-structure nil "Options concerning structure editing in Org-mode." :tag "Org Structure" :group 'org) (defcustom org-adapt-indentation t "Non-nil means, adapt indentation when promoting and demoting. When this is set and the *entire* text in an entry is indented, the indentation is increased by one space in a demotion command, and decreased by one in a promotion command. If any line in the entry body starts at column 0, indentation is not changed at all." :group 'org-structure :type 'boolean) (defcustom org-cycle-emulate-tab t "Where should org-cycle' emulate TAB. nil Never white Only in completely white lines t Everywhere except in headlines" :group 'org-structure :type '(choice (const :tag "Never" nil) (const :tag "Only in completely white lines" white) (const :tag "Everywhere except in headlines" t) )) (defconst org-time-stamp-formats '("<%Y-%m-%d %a>" . "<%Y-%m-%d %a %H:%M>") "Formats for format-time-string' which are used for time stamps. It is not recommended to change this constant.")  Carsten Dominik committed Jan 14, 2005 659 660 661 662 663 664 665 666 667 668 669 670 (defcustom org-show-following-heading t "Non-nil means, show heading following match in org-occur'. When doing an org-occur' it is useful to show the headline which follows the match, even if they do not match the regexp. This makes it easier to edit directly inside the sparse tree. However, if you use org-occur mainly as an overview, the following headlines are unnecessary clutter." :group 'org-structure :type 'boolean)  Richard M. Stallman committed Dec 06, 2004 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 (defgroup org-link nil "Options concerning links in Org-mode." :tag "Org Link" :group 'org) (defcustom org-allow-space-in-links t "Non-nil means, file names in links may contain space characters. When nil, it becomes possible to put several links into a line." :group 'org-link :type 'boolean) (defcustom org-line-numbers-in-file-links t "Non-nil means, file links from org-store-link' contain line numbers. The line number will be added to the file name with :NNN and interpreted by the command org-open-at-point'. Using a prefix arg to the command \\[org-store-link] (org-store-link') negates this setting for the duration of the command." :group 'org-link :type 'boolean) (defcustom org-keep-stored-link-after-insertion nil "Non-nil means, keep link in list for entire session. The command org-store-link' adds a link pointing to the current location to an internal list. These links accumulate during a session. The command org-insert-link' can be used to insert links into any Org-mode file (offering completion for all stored links). When this option is nil, every link which has been inserted once using C-c C-l' will be removed from the list, to make completing the unused links more efficient." :group 'org-link :type 'boolean) (defcustom org-link-frame-setup '((vm . vm-visit-folder-other-frame) (gnus . gnus-other-frame) (file . find-file-other-window)) "Setup the frame configuration for following links. When following a link with Emacs, it may often be useful to display this link in another window or frame. This variable can be used to set this up for the different types of links. For VM, use any of vm-visit-folder vm-visit-folder-other-frame For Gnus, use any of gnus gnus-other-frame For FILE, use any of find-file find-file-other-window find-file-other-frame For the calendar, use the variable calendar-setup'. For BBDB, it is currently only possible to display the matches in another window." :group 'org-link :type '(list (cons (const vm) (choice (const vm-visit-folder) (const vm-visit-folder-other-window) (const vm-visit-folder-other-frame))) (cons (const gnus) (choice (const gnus) (const gnus-other-frame))) (cons (const file) (choice (const find-file) (const find-file-other-window) (const find-file-other-frame))))) (defcustom org-usenet-links-prefer-google nil "Non-nil means, org-store-link' will create web links to google groups. When nil, Gnus will be used for such links. Using a prefix arg to the command \\[org-store-link] (org-store-link') negates this setting for the duration of the command." :group 'org-link :type 'boolean) (defcustom org-open-non-existing-files nil "Non-nil means, org-open-file' will open non-existing file. When nil, an error will be generated." :group 'org-link :type 'boolean) (defcustom org-confirm-shell-links t "Non-nil means, ask for confirmation before executing shell links. The default is true, to keep new users from shooting into their own foot." :group 'org-link :type 'boolean) (defconst org-file-apps-defaults-linux '((t . emacs) ("jpg" . "xv %s") ("gif" . "xv %s") ("ppm" . "xv %s") ("pgm" . "xv %s") ("pbm" . "xv %s") ("tif" . "xv %s") ("png" . "xv %s") ("ps" . "gv %s") ("ps.gz" . "gv %s") ("eps" . "gv %s") ("eps.gz" . "gv %s") ("dvi" . "xdvi %s") ("mpeg" . "plaympeg %s") ("mp3" . "plaympeg %s") ("fig" . "xfig %s") ("pdf" . "acroread %s") ("doc" . "soffice %s") ("ppt" . "soffice %s") ("pps" . "soffice %s") ("html" . "netscape -remote openURL(%s,new-window)") ("htm" . "netscape -remote openURL(%s,new-window)") ("xs" . "soffice %s")) "Default file applications on a UNIX/LINUX system. See org-file-apps'.") (defconst org-file-apps-defaults-macosx '((t . "open %s") ("ps" . "gv %s") ("ps.gz" . "gv %s") ("eps" . "gv %s") ("eps.gz" . "gv %s") ("dvi" . "xdvi %s") ("fig" . "xfig %s")) "Default file applications on a MacOS X system. The system \"open\" is known as a default, but we use X11 applications for some files for which the OS does not have a good default. See org-file-apps'.") (defconst org-file-apps-defaults-windowsnt '((t . (w32-shell-execute "open" file))) "Default file applications on a Windows NT system. The system \"open\" is used for most files. See org-file-apps'.") (defcustom org-file-apps '( ("txt" . emacs) ("tex" . emacs) ("ltx" . emacs) ("org" . emacs) ("el" . emacs) ) "External applications for opening file:path' items in a document. Org-mode uses system defaults for different file types, but you can use this variable to set the application for a given file extension. The entries in this list are cons cells with a file extension and the corresponding command. Possible values for the command are: emacs' The file will be visited by the current Emacs process. default' Use the default application for this file type. string A command to be executed by a shell. %s will be replaced by the path to the file. sexp A lisp form which will be evaluated. The file path will be available in the lisp variable file'. For more examples, see the system specific constants org-file-apps-defaults-macosx' org-file-apps-defaults-windowsnt' org-file-apps-defaults-linux'." :group 'org-link :type '(repeat (cons (string :tag "Extension") (choice :value "" (const :tag "Visit with Emacs" 'emacs) (const :tag "Use system default" 'default) (string :tag "Command") (sexp :tag "Lisp form"))))) (defgroup org-remember nil "Options concerning interaction with remember.el." :tag "Org Remember" :group 'org) (defcustom org-directory "~/org" "Directory with org files. This directory will be used as default to prompt for org files. Used by the hooks for remember.el." :group 'org-remember :type 'directory) (defcustom org-default-notes-file "~/.notes" "Default target for storing notes. Used by the hooks for remember.el. This can be a string, or nil to mean the value of remember-data-file'." :group 'org-remember :type '(choice (const :tag "Default from remember-data-file" nil) file)) (defcustom org-reverse-note-order nil "Non-nil means, store new notes at the beginning of a file or entry. When nil, new notes will be filed to the end of a file or entry." :group 'org-remember :type '(choice (const :tag "Reverse always" t) (const :tag "Reverse never" nil) (repeat :tag "By file name regexp" (cons regexp boolean)))) (defgroup org-table nil "Options concerning tables in Org-mode." :tag "Org Table" :group 'org)  Carsten Dominik committed Jan 14, 2005 877 (defcustom org-enable-table-editor 'optimized  Richard M. Stallman committed Dec 06, 2004 878  "Non-nil means, lines starting with \"|\" are handled by the table editor.  Carsten Dominik committed Jan 14, 2005 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 When nil, such lines will be treated like ordinary lines. When equal to the symbol optimized', the table editor will be optimized to do the following - Use automatic overwrite mode in front of whitespace in table fields. This make the structure of the table stay in tact as long as the edited field does not exceed the column width. - Minimize the number of realigns. Normally, the table is aligned each time TAB or RET are pressed to move to another field. With optimization this happens only if changes to a field might have changed the column width. Optimization requires replacing the functions self-insert-command', delete-char', and backward-delete-char' in Org-mode buffers, with a slight (in fact: unnoticable) speed impact for normal typing. Org-mode is very good at guessing when a re-align will be necessary, but you can always force one with C-c C-c'. I you would like to use the optimized version in Org-mode, but the un-optimized version in OrgTbl-mode, see the variable orgtbl-optimized'. This variable can be used to turn on and off the table editor during a session, but in order to toggle optimization, a restart is required."  Richard M. Stallman committed Dec 06, 2004 900  :group 'org-table  Carsten Dominik committed Jan 14, 2005 901 902 903 904  :type '(choice (const :tag "off" nil) (const :tag "on" t) (const :tag "on, optimized" optimized)))  Richard M. Stallman committed Dec 06, 2004 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349  (defcustom org-table-default-size "5x2" "The default size for newly created tables, Columns x Rows." :group 'org-table :type 'string) (defcustom org-table-automatic-realign t "Non-nil means, automatically re-align table when pressing TAB or RETURN. When nil, aligning is only done with \\[org-table-align], or after column removal/insertion." :group 'org-table :type 'boolean) (defcustom org-table-spaces-around-separators '(1 . 1) "The number of spaces to be placed before and after separators." :group 'org-table :type '(cons (number :tag "Before \"|\"") (number :tag " After \"|\""))) (defcustom org-table-spaces-around-invisible-separators '(1 . 2) "The number of spaces to be placed before and after separators. This option applies when the column separators have been made invisible." :group 'org-table :type '(cons (number :tag "Before \"|\"") (number :tag " After \"|\""))) (defcustom org-table-number-regexp "^[<>]?[-+^.0-9]*[0-9][-+^.0-9eEdDx()%]*" "Regular expression for recognizing numbers in table columns. If a table column contains mostly numbers, it will be aligned to the right. If not, it will be aligned to the left. The default value of this option is a regular expression which allows anything which looks remotely like a number as used in scientific context. For example, all of the following will be considered a number: 12 12.2 2.4e-08 2x10^12 4.034+-0.02 2.7(10) >3.5 Other options offered by the customize interface are more restrictive." :group 'org-table :type '(choice (const :tag "Positive Integers" "^[0-9]+") (const :tag "Integers" "^[-+]?[0-9]+") (const :tag "Floating Point Numbers" "^[-+]?\$$[0-9]*\\.[0-9]+\\|[0-9]+\\.[0-9]*\$$") (const :tag "Floating Point Number or Integer" "^[-+]?\$$[0-9]*\\.[0-9]+\\|[0-9]+\\.?[0-9]*\$$") (const :tag "Exponential, Floating point, Integer" "^[-+]?[0-9.]+\$$[eEdD][-+0-9]+\$$?") (const :tag "Very General Number-Like" "^[<>]?[-+^.0-9]*[0-9][-+^.0-9eEdDx()%]*") (string :tag "Regexp:"))) (defcustom org-table-number-fraction 0.5 "Fraction of numbers in a column required to make the column align right. In a column all non-white fields are considered. If at least this fraction of fields is matched by org-table-number-fraction', alignment to the right border applies." :group 'org-table :type 'number) (defcustom org-export-highlight-first-table-line t "Non-nil means, highlight the first table line. In HTML export, this means use instead of . In tables created with table.el, this applies to the first table line. In Org-mode tables, all lines before the first horizontal separator line will be formatted with tags." :group 'org-table :type 'boolean) (defcustom org-table-tab-recognizes-table.el t "Non-nil means, TAB will automatically notice a table.el table. When it sees such a table, it moves point into it and - if necessary - calls table-recognize-table'." :group 'org-table :type 'boolean) (defcustom org-export-prefer-native-exporter-for-tables nil "Non-nil means, always export tables created with table.el natively. Natively means, use the HTML code generator in table.el. When nil, Org-mode's own HTML generator is used when possible (i.e. if the table does not use row- or column-spanning). This has the advantage, that the automatic HTML conversions for math symbols and sub/superscripts can be applied. Org-mode's HTML generator is also much faster." :group 'org-table :type 'boolean) (defcustom org-enable-fixed-width-editor t "Non-nil means, lines starting with \":\" are treated as fixed-width. This currently only means, they are never auto-wrapped. When nil, such lines will be treated like ordinary lines." :group 'org-table :type 'boolean) (defgroup org-export nil "Options for exporting org-listings." :tag "Org Export" :group 'org) (defcustom org-export-language-setup '(("en" "Author" "Date" "Table of Contents") ("da" "Ophavsmand" "Dato" "Indhold") ("de" "Autor" "Datum" "Inhaltsverzeichnis") ("es" "Autor" "Fecha" "\xccndice") ("fr" "Auteur" "Date" "Table des Mati\xe8res") ("it" "Autore" "Data" "Indice") ("nl" "Auteur" "Datum" "Inhoudsopgave") ("nn" "Forfattar" "Dato" "Innhold") ;; nn = Norsk (nynorsk) ("sv" "F\xf6rfattarens" "Datum" "Inneh\xe5ll")) "Terms used in export text, translated to different languages. Use the variable org-export-default-language' to set the language, or use the +OPTION lines for a per-file setting." :group 'org-export :type '(repeat (list (string :tag "HTML language tag") (string :tag "Author") (string :tag "Date") (string :tag "Table of Contents")))) (defcustom org-export-default-language "en" "The default language of HTML export, as a string. This should have an association in org-export-language-setup'" :group 'org-export :type 'string) (defcustom org-export-headline-levels 3 "The last level which is still exported as a headline. Inferior levels will produce itemize lists when exported. Note that a numeric prefix argument to an exporter function overrides this setting. This option can also be set with the +OPTIONS line, e.g. \"H:2\"." :group 'org-export :type 'number) (defcustom org-export-with-section-numbers t "Non-nil means, add section numbers to headlines when exporting. This option can also be set with the +OPTIONS line, e.g. \"num:t\"." :group 'org-export :type 'boolean) (defcustom org-export-with-toc t "Non-nil means, create a table of contents in exported files. The TOC contains headlines with levels up toorg-export-headline-levels'. Headlines which contain any TODO items will be marked with \"(*)\" in ASCII export, and with red color in HTML output. In HTML output, the TOC will be clickable. This option can also be set with the +OPTIONS line, e.g. \"toc:nil\"." :group 'org-export :type 'boolean) (defcustom org-export-preserve-breaks nil "Non-nil means, preserve all line breaks when exporting. Normally, in HTML output paragraphs will be reformatted. In ASCII export, line breaks will always be preserved, regardless of this variable. This option can also be set with the +OPTIONS line, e.g. \"\\n:t\"." :group 'org-export :type 'boolean) (defcustom org-export-html-inline-images t "Non-nil means, inline images into exported HTML pages. The link will still be to the original location of the image file. So if you are moving the page, lets say to your public HTML site, you will have to move the image and maybe change the link." :group 'org-export :type 'boolean) (defcustom org-export-html-expand t "Non-nil means, for HTML export, treat @<...> as HTML tag. When nil, these tags will be exported as plain text and therefore not be interpreted by a browser. This option can also be set with the +OPTIONS line, e.g. \"@:nil\"." :group 'org-export :type 'boolean) (defcustom org-export-with-fixed-width t "Non-nil means, lines starting with \":\" will be in fixed width font. This can be used to have preformatted text, fragments of code etc. For example : ;; Some Lisp examples : (while (defc cnt) : (ding)) will be looking just like this in also HTML. In ASCII export, this option has no effect. This option can also be set with the +OPTIONS line, e.g. \"::nil\"." :group 'org-export :type 'boolean) (defcustom org-export-with-tables t "Non-nil means, lines starting with \"|\" define a table For example: | Name | Address | Birthday | |-------------+----------+-----------| | Arthur Dent | England | 29.2.2100 | In ASCII export, this option has no effect. This option can also be set with the +OPTIONS line, e.g. \"|:nil\"." :group 'org-export :type 'boolean) (defcustom org-export-html-table-tag "" "The HTML tag used to start a table. This must be a tag, but you may change the options like borders and spacing." :group 'org-export :type 'string) (defcustom org-export-with-emphasize t "Non-nil means, interprete *word*, /word/, and _word_ as emphasized text. If the export target supports emphasizing text, the word will be typeset in bold, italic, or underlined, respectively. Works only for single words, but you can say: I *really* *mean* *this*. In ASCII export, this option has no effect. This option can also be set with the +OPTIONS line, e.g. \"*:nil\"." :group 'org-export :type 'boolean) (defcustom org-match-sexp-depth 3 "Number of stacked braces for sub/superscript matching. This has to be set before loading org.el to be effective." :group 'org-export :type 'integer) ;; FIXME: Should () parens be removed as well in sub/superscripts? (defcustom org-export-with-sub-superscripts t "Non-nil means, interprete \"_\" and \"^\" for export. When this option is turned on, you can use TeX-like syntax for sub- and superscripts. Several characters after \"_\" or \"^\" will be considered as a single item - so grouping with {} is normally not needed. For example, the following things will be parsed as single sub- or superscripts. 10^24 or 10^tau several digits will be considered 1 item 10^-12 or 10^-tau a leading sign with digits or a word x^2-y^3 will be read as x^2 - y^3, because items are terminated by almost any nonword/nondigit char. x_{i^2} or x^(2-i) braces or parenthesis do grouping. Still, ambiguity is possible - so when in doubt use {} to enclose the sub/superscript. In ASCII export, this option has no effect. This option can also be set with the +OPTIONS line, e.g. \"^:nil\"." :group 'org-export :type 'boolean) (defcustom org-export-with-TeX-macros t "Non-nil means, interprete simple TeX-like macros when exporting. For example, HTML export converts \\alpha to α and \\AA to Å. No only real TeX macros will work here, but the standard HTML entities for math can be used as macro names as well. For a list of supported names in HTML export, see the constant org-html-entities'. In ASCII export, this option has no effect. This option can also be set with the +OPTIONS line, e.g. \"TeX:nil\"." :group 'org-export :type 'boolean) (defcustom org-export-html-with-timestamp nil "Non-nil means, write org-export-html-html-helper-timestamp' into the exported html text. Otherwise, the buffer will just be saved to a file." :group 'org-export :type 'boolean) (defcustom org-export-html-html-helper-timestamp " \n" "The HTML tag used as timestamp delimiter for HTML-helper-mode." :group 'org-export :type 'string) (defcustom org-export-ascii-show-new-buffer t "Non-nil means, popup buffer containing the exported ASCII text. Otherwise the buffer will just be saved to a file and stay hidden." :group 'org-export :type 'boolean) (defcustom org-export-html-show-new-buffer nil "Non-nil means, popup buffer containing the exported html text. Otherwise, the buffer will just be saved to a file and stay hidden." :group 'org-export :type 'boolean) (defgroup org-faces nil "Faces for highlighting in Org-mode." :tag "Org Faces" :group 'org) (defface org-level-1-face ;; font-lock-function-name-face '((((type tty) (class color)) (:foreground "blue" :weight bold)) (((class color) (background light)) (:foreground "Blue")) (((class color) (background dark)) (:foreground "LightSkyBlue")) (t (:inverse-video t :bold t))) "Face used for level 1 headlines." :group 'org-faces) (defface org-level-2-face ;; font-lock-variable-name-face '((((type tty) (class color)) (:foreground "yellow" :weight light)) (((class color) (background light)) (:foreground "DarkGoldenrod")) (((class color) (background dark)) (:foreground "LightGoldenrod")) (t (:bold t :italic t))) "Face used for level 2 headlines." :group 'org-faces) (defface org-level-3-face ;; font-lock-keyword-face '((((type tty) (class color)) (:foreground "cyan" :weight bold)) (((class color) (background light)) (:foreground "Purple")) (((class color) (background dark)) (:foreground "Cyan")) (t (:bold t))) "Face used for level 3 headlines." :group 'org-faces) (defface org-level-4-face ;; font-lock-comment-face '((((type tty pc) (class color) (background light)) (:foreground "red")) (((type tty pc) (class color) (background dark)) (:foreground "red1")) (((class color) (background light)) (:foreground "Firebrick")) (((class color) (background dark)) (:foreground "chocolate1")) (t (:bold t :italic t))) "Face used for level 4 headlines." :group 'org-faces) (defface org-level-5-face ;; font-lock-type-face '((((type tty) (class color)) (:foreground "green")) (((class color) (background light)) (:foreground "ForestGreen")) (((class color) (background dark)) (:foreground "PaleGreen")) (t (:bold t :underline t))) "Face used for level 5 headlines." :group 'org-faces) (defface org-level-6-face ;; font-lock-constant-face '((((type tty) (class color)) (:foreground "magenta")) (((class color) (background light)) (:foreground "CadetBlue")) (((class color) (background dark)) (:foreground "Aquamarine")) (t (:bold t :underline t))) "Face used for level 6 headlines." :group 'org-faces) (defface org-level-7-face ;; font-lock-builtin-face '((((type tty) (class color)) (:foreground "blue" :weight light)) (((class color) (background light)) (:foreground "Orchid")) (((class color) (background dark)) (:foreground "LightSteelBlue")) (t (:bold t))) "Face used for level 7 headlines." :group 'org-faces) (defface org-level-8-face ;;font-lock-string-face '((((type tty) (class color)) (:foreground "green")) (((class color) (background light)) (:foreground "RosyBrown")) (((class color) (background dark)) (:foreground "LightSalmon")) (t (:italic t))) "Face used for level 8 headlines." :group 'org-faces) (defface org-warning-face ;; font-lock-warning-face '((((type tty) (class color)) (:foreground "red")) (((class color) (background light)) (:foreground "Red" :bold t)) (((class color) (background dark)) (:foreground "Pink" :bold t)) (t (:inverse-video t :bold t))) "Face for deadlines and TODO keyords." :group 'org-faces) ;; Inheritance does not work for xemacs, unfortunately. ;; We just copy the definitions and waste some space.... (defface org-deadline-announce-face '((((type tty) (class color)) (:foreground "blue" :weight bold)) (((class color) (background light)) (:foreground "Blue")) (((class color) (background dark)) (:foreground "LightSkyBlue")) (t (:inverse-video t :bold t))) "Face for upcoming deadlines." :group 'org-faces) (defface org-scheduled-today-face '((((type tty) (class color)) (:foreground "green")) (((class color) (background light)) (:foreground "DarkGreen")) (((class color) (background dark)) (:foreground "PaleGreen")) (t (:bold t :underline t))) "Face for items scheduled for a certain day." :group 'org-faces) (defface org-scheduled-previously-face '((((type tty pc) (class color) (background light)) (:foreground "red")) (((type tty pc) (class color) (background dark)) (:foreground "red1")) (((class color) (background light)) (:foreground "Firebrick")) (((class color) (background dark)) (:foreground "chocolate1")) (t (:bold t :italic t))) "Face for items scheduled previously, and not yet done." :group 'org-faces) (defface org-link-face '((((type tty) (class color)) (:foreground "cyan" :weight bold)) (((class color) (background light)) (:foreground "Purple")) (((class color) (background dark)) (:foreground "Cyan")) (t (:bold t))) "Face for links." :group 'org-faces) (defface org-done-face ;; font-lock-type-face '((((type tty) (class color)) (:foreground "green")) (((class color) (background light)) (:foreground "ForestGreen" :bold t)) (((class color) (background dark)) (:foreground "PaleGreen" :bold t)) (t (:bold t :underline t))) "Face used for DONE." :group 'org-faces) (defface org-table-face ;; font-lock-function-name-face '((((type tty) (class color)) (:foreground "blue" :weight bold)) (((class color) (background light)) (:foreground "Blue")) (((class color) (background dark)) (:foreground "LightSkyBlue")) (t (:inverse-video t :bold t))) "Face used for tables." :group 'org-faces) (defvar org-level-faces '( org-level-1-face org-level-2-face org-level-3-face org-level-4-face org-level-5-face org-level-6-face org-level-7-face org-level-8-face )) (defvar org-n-levels (length org-level-faces)) ;; Tell the compiler about dynamically scoped variables, ;; and variables from other packages (eval-when-compile (defvar zmacs-regions) (defvar org-transient-mark-mode)  Carsten Dominik committed Jan 14, 2005 1350 1351  (defvar org-old-auto-fill-inhibit-regexp) (defvar orgtbl-mode-menu)  Richard M. Stallman committed Dec 06, 2004 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407  (defvar org-html-entities) (defvar org-goto-start-pos) (defvar org-cursor-color) (defvar org-time-was-given) (defvar org-ts-what) (defvar timecnt) (defvar levels-open) (defvar title) (defvar author) (defvar email) (defvar text) (defvar entry) (defvar date) (defvar language) (defvar options) (defvar ans1) (defvar ans2) (defvar starting-day) (defvar include-all-loc) (defvar vm-message-pointer) (defvar vm-folder-directory) (defvar wl-summary-buffer-elmo-folder) (defvar wl-summary-buffer-folder-name) (defvar gnus-group-name) (defvar gnus-article-current) (defvar w3m-current-url) (defvar org-selected-point) (defvar calendar-mode-map) (defvar remember-save-after-remembering) (defvar remember-data-file)) ;;; Define the mode (defvar org-mode-map (copy-keymap outline-mode-map) "Keymap for Org-mode.") (defvar org-struct-menu) (defvar org-org-menu) ;;;###autoload (defun org-mode (&optional arg) "Outline-based notes management and organizer, alias \"Carstens outline-mode for keeping track of everything.\" Org-mode develops organizational tasks around a NOTES file which contains information about projects as plain text. Org-mode is implemented on top of outline-mode, which is ideal to keep the content of large files well structured. It supports ToDo items, deadlines and time stamps, which magically appear in the diary listing of the Emacs calendar. Tables are easily created with a built-in table editor. Plain text URL-like links connect to websites, emails (VM), Usenet messages (Gnus), BBDB entries, and any files related to the project. For printing and sharing of notes, an Org-mode file (or a part of it) can be exported as a well-structured ASCII or HTML file.  Carsten Dominik committed Jan 14, 2005 1408 The following commands are available:  Richard M. Stallman committed Dec 06, 2004 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419  \\{org-mode-map}" (interactive "P") (outline-mode) (setq major-mode 'org-mode) (setq mode-name "Org") (use-local-map org-mode-map) (easy-menu-add org-org-menu) (org-install-agenda-files-menu) (setq outline-regexp "\\*+") (if org-startup-truncated (setq truncate-lines t))  Carsten Dominik committed Jan 14, 2005 1420  (org-set-regexps-and-options)  Richard M. Stallman committed Dec 06, 2004 1421 1422 1423  (set (make-local-variable 'font-lock-unfontify-region-function) 'org-unfontify-region) ;; Activate before-change-function  Carsten Dominik committed Jan 14, 2005 1424 1425  (set (make-local-variable 'org-table-may-need-update) t) (make-local-hook 'before-change-functions) ;; needed for XEmacs  Richard M. Stallman committed Dec 06, 2004 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565  (add-hook 'before-change-functions 'org-before-change-function nil 'local) ;; Inhibit auto-fill for headers, tables and fixed-width lines. (set (make-local-variable 'auto-fill-inhibit-regexp) (concat "\\*" (if (or org-enable-table-editor org-enable-fixed-width-editor) (concat "\\|[ \t]*[" (if org-enable-table-editor "|" "") (if org-enable-fixed-width-editor ":" "") "]")))) ;; Hook, and startup actions (if (or arg (and org-insert-mode-line-in-empty-file (= (point-min) (point-max)))) (save-excursion (goto-char (point-min)) (insert " -*- mode: org -*-\n\n"))) (run-hooks 'org-mode-hook) (if org-startup-with-deadline-check (call-interactively 'org-check-deadlines) (if org-startup-folded (org-cycle t)))) ;;; Font-Lock stuff (defvar org-mouse-map (make-sparse-keymap)) (define-key org-mouse-map (if org-xemacs-p [button2] [mouse-2]) 'org-open-at-mouse) (define-key org-mouse-map (if org-xemacs-p [button3] [mouse-3]) 'org-find-file-at-mouse) (require 'font-lock) (defconst org-link-regexp (if org-allow-space-in-links "\$$https?\\|ftp\\|mailto\\|file\\|news\\|bbdb\\|vm\\|wl\\|rmail\\|gnus\\|shell\$$:\$$[^\t\n\r]+[^ \t\n\r]\$$" "\$$https?\\|ftp\\|mailto\\|file\\|news\\|bbdb\\|vm\\|wl\\|rmail\\|gnus\\|shell\$$:\$$[^ \t\n\r]+\$$" ) "Regular expression for matching links.") (defconst org-ts-lengths (cons (length (format-time-string (car org-time-stamp-formats))) (length (format-time-string (cdr org-time-stamp-formats)))) "This holds the lengths of the two different time formats.") (defconst org-ts-regexp "<\$$[0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}[^\r\n>]*\$$>" "Regular expression for fast time stamp matching.") (defconst org-ts-regexp1 "\$$\\([0-9]\\{4\\}\$$-\$$[0-9]\\{2\\}\$$-\$$[0-9]\\{2\\}\$$\$$[^0-9>\r\n]*\$$\$$\\([0-9]\\{2\\}\$$:\$$[0-9]\\{2\\}\$$\\)?\\)" "Regular expression matching time strings for analysis.") (defconst org-ts-regexp2 (concat "<" org-ts-regexp1 ">") "Regular expression matching time stamps, with groups.") (defconst org-tr-regexp (concat org-ts-regexp "--?-?" org-ts-regexp) "Regular expression matching a time stamp range.") (defconst org-tsr-regexp (concat org-ts-regexp "\$$--?-?" org-ts-regexp "\$$?") "Regular expression matching a time stamp or time stamp range.") (defun org-activate-links (limit) "Run through the buffer and add overlays to links." (if (re-search-forward org-link-regexp limit t) (progn (add-text-properties (match-beginning 0) (match-end 0) (list 'mouse-face 'highlight 'keymap org-mouse-map)) t))) (defun org-activate-dates (limit) "Run through the buffer and add overlays to links." (if (re-search-forward org-tsr-regexp limit t) (progn (add-text-properties (match-beginning 0) (match-end 0) (list 'mouse-face 'highlight 'keymap org-mouse-map)) t))) (defun org-font-lock-level () (save-excursion (org-back-to-heading t) (- (match-end 0) (match-beginning 0)))) (defun org-set-font-lock-defaults () (let ((org-font-lock-extra-keywords (list '(org-activate-links (0 'org-link-face)) '(org-activate-dates (0 'org-link-face)) (list (concat "^\\*+[ \t]*" org-not-done-regexp) '(1 'org-warning-face t)) (list (concat "\\[#[A-Z]\") '(0 'org-warning-face t)) (list (concat "\\<" org-deadline-string) '(0 'org-warning-face t)) (list (concat "\\<" org-scheduled-string) '(0 'org-warning-face t)) ;; '("\$$\\s-\\|^\$$\$$\\*\\([a-zA-Z]+\$$\\*\\)\$$[^a-zA-Z*]\\|\$$" ;; (3 'bold)) ;; '("\$$\\s-\\|^\$$\$$/\\([a-zA-Z]+\$$/\\)\$$[^a-zA-Z*]\\|\$$" ;; (3 'italic)) ;; '("\$$\\s-\\|^\$$\$$_\\([a-zA-Z]+\$$_\\)\$$[^a-zA-Z*]\\|\$$" ;; (3 'underline)) '("\\" (0 'org-warning-face t)) (list (concat "^\\*+[ \t]*\\<\$$" org-comment-string "\$$\\>") '(1 'org-warning-face t)) '("^#.*" (0 'font-lock-comment-face t)) (list (concat "^[*]+ +\\<\$$" org-done-string "\$$\\>") '(1 'org-done-face t)) '("^[ \t]*\$$\\(|\\|\\+-[-+]\$$.*\\S-\\)" (1 'org-table-face t)) '("^[ \t]*\$$:.*\$$" (1 'org-table-face t))))) (set (make-local-variable 'org-font-lock-keywords) (append (if org-noutline-p ; FIXME: I am not sure if eval will work ; on XEmacs if noutline is ever ported '((eval . (list "^\$$\\*+\$$.*" 0 '(nth (% (- (match-end 1) (match-beginning 1) 1) org-n-levels) org-level-faces) nil t))) '(("^\$$\\(\\*+\$$[^\r\n]*\\)[\n\r]" (1 (nth (% (- (match-end 2) (match-beginning 2) 1) org-n-levels) org-level-faces) nil t)))) org-font-lock-extra-keywords)) (set (make-local-variable 'font-lock-defaults) '(org-font-lock-keywords t nil nil backward-paragraph)) (kill-local-variable 'font-lock-keywords) nil)) (defvar org-font-lock-keywords nil) (defun org-unfontify-region (beg end &optional maybe_loudly) "Remove fontification and activation overlays from links." (font-lock-default-unfontify-region beg end) (let* ((modified (buffer-modified-p)) ;; FIXME: Why did I add this??? (buffer-undo-list t) (inhibit-read-only t) (inhibit-point-motion-hooks t) (inhibit-modification-hooks t) deactivate-mark buffer-file-name buffer-file-truename) (remove-text-properties beg end '(mouse-face nil keymap nil)))) ;;; Visibility cycling (defvar org-cycle-global-status nil) (defvar org-cycle-subtree-status nil) (defun org-cycle (&optional arg)  Carsten Dominik committed Jan 14, 2005 1566  "Visibility cycling for org-mode.  Richard M. Stallman committed Dec 06, 2004 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598  - When this function is called with a prefix argument, rotate the entire buffer through 3 states (global cycling) 1. OVERVIEW: Show only top-level headlines. 2. CONTENTS: Show all headlines of all levels, but no body text. 3. SHOW ALL: Show everything. - When point is at the beginning of a headline, rotate the subtree started by this line through 3 different states (local cycling) 1. FOLDED: Only the main headline is shown. 2. CHILDREN: The main headline and the direct children are shown. From this state, you can move to one of the children and zoom in further. 3. SUBTREE: Show the entire subtree, including body text. - When point is not at the beginning of a headline, execute indent-relative', like TAB normally does. See the option org-cycle-emulate-tab' for details. - Special case: if point is the the beginning of the buffer and there is no headline in line 1, this function will act as if called with prefix arg." (interactive "P") (if (and (bobp) (not (looking-at outline-regexp))) ; special case: use global cycling (setq arg t)) (cond ((org-at-table-p 'any) ;; Enter the table or move to the next field in the table (or (org-table-recognize-table.el)  Carsten Dominik committed Jan 14, 2005 1599 1600 1601  (progn (org-table-justify-field-maybe) (org-table-next-field))))  Richard M. Stallman committed Dec 06, 2004 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825  (arg ;; Global cycling (cond ((and (eq last-command this-command) (eq org-cycle-global-status 'overview)) ;; We just created the overview - now do table of contents ;; This can be slow in very large buffers, so indicate action (message "CONTENTS...") (save-excursion ;; Visit all headings and show their offspring (goto-char (point-max)) (catch 'exit (while (and (progn (condition-case nil (outline-previous-visible-heading 1) (error (goto-char (point-min)))) t) (looking-at outline-regexp)) (show-branches) (if (bobp) (throw 'exit nil)))) (message "CONTENTS...done")) (setq org-cycle-global-status 'contents)) ((and (eq last-command this-command) (eq org-cycle-global-status 'contents)) ;; We just showed the table of contents - now show everything (show-all) (message "SHOW ALL") (setq org-cycle-global-status 'all)) (t ;; Default action: go to overview (hide-sublevels 1) (message "OVERVIEW") (setq org-cycle-global-status 'overview)))) ((save-excursion (beginning-of-line 1) (looking-at outline-regexp)) ;; At a heading: rotate between three different views (org-back-to-heading) (let ((goal-column 0) beg eoh eol eos nxh) ;; First, some boundaries (save-excursion (org-back-to-heading) (setq beg (point)) (save-excursion (beginning-of-line 2) (while (and (not (eobp)) ;; this is like next-line' (get-char-property (1- (point)) 'invisible)) (beginning-of-line 2)) (setq eol (point))) (outline-end-of-heading) (setq eoh (point)) (outline-end-of-subtree) (setq eos (point)) (outline-next-heading) (setq nxh (point))) ;; Find out what to do next and set this-command' (cond ((= eos eoh) ;; Nothing is hidden behind this heading (message "EMPTY ENTRY") (setq org-cycle-subtree-status nil)) ((>= eol eos) ;; Entire subtree is hidden in one line: open it (show-entry) (show-children) (message "CHILDREN") (setq org-cycle-subtree-status 'children)) ((and (eq last-command this-command) (eq org-cycle-subtree-status 'children)) ;; We just showed the children, now show everything. (show-subtree) (message "SUBTREE") (setq org-cycle-subtree-status 'subtree)) (t ;; Default action: hide the subtree. (hide-subtree) (message "FOLDED") (setq org-cycle-subtree-status 'folded))))) ;; TAB emulation (buffer-read-only (org-back-to-heading)) ((if (and (eq org-cycle-emulate-tab 'white) (save-excursion (beginning-of-line 1) (looking-at "[ \t]+"))) t (eq org-cycle-emulate-tab t)) (if (and (looking-at "[ \n\r\t]") (string-match "^[ \t]*\$" (buffer-substring (point-at-bol) (point)))) (progn (beginning-of-line 1) (and (looking-at "[ \t]+") (replace-match "")))) (indent-relative)) (t (save-excursion (org-back-to-heading) (org-cycle))))) (defvar org-goto-window-configuration nil) (defvar org-goto-marker nil) (defvar org-goto-map (make-sparse-keymap)) (let ((cmds '(isearch-forward isearch-backward)) cmd) (while (setq cmd (pop cmds)) (substitute-key-definition cmd cmd org-goto-map global-map))) (define-key org-goto-map [(return)] 'org-goto-ret) (define-key org-goto-map [(left)] 'org-goto-left) (define-key org-goto-map [(right)] 'org-goto-right) (define-key org-goto-map [(?q)] 'org-goto-quit) (define-key org-goto-map [(control ?g)] 'org-goto-quit) (define-key org-goto-map [(tab)] 'org-cycle) (define-key org-goto-map [(down)] 'outline-next-visible-heading) (define-key org-goto-map [(up)] 'outline-previous-visible-heading) (define-key org-goto-map "n" 'outline-next-visible-heading) (define-key org-goto-map "p" 'outline-previous-visible-heading) (define-key org-goto-map "f" 'outline-forward-same-level) (define-key org-goto-map "b" 'outline-backward-same-level) (define-key org-goto-map "u" 'outline-up-heading) (define-key org-goto-map "\C-c\C-n" 'outline-next-visible-heading) (define-key org-goto-map "\C-c\C-p" 'outline-previous-visible-heading) (define-key org-goto-map "\C-c\C-f" 'outline-forward-same-level) (define-key org-goto-map "\C-c\C-b" 'outline-backward-same-level) (define-key org-goto-map "\C-c\C-u" 'outline-up-heading) (let ((l '(1 2 3 4 5 6 7 8 9 0))) (while l (define-key org-goto-map (int-to-string (pop l)) 'digit-argument))) (defconst org-goto-help "Select a location to jump to, press RET $Up]/[Down]=next/prev headline TAB=cycle visibility RET=select [Q]uit") (defun org-goto () "Go to a different location of the document, keeping current visibility. When you want to go to a different location in a document, the fastest way is often to fold the entire buffer and then dive into the tree. This method has the disadvantage, than the previous location will be folded, and that can be unwanted. This command works around this by showing a copy of the current buffer in overview mode. You can dive into the tree in that copy, to find the location you want to reach. When pressing RET, the command returns to the original buffer in which the visibility is still unchanged. It then jumps to the new location, making it and the headline hierarchy above it visible." (interactive) (let* ((org-goto-start-pos (point)) (selected-point (org-get-location (current-buffer) org-goto-help))) (if selected-point (progn (goto-char selected-point) (if (org-invisible-p) (org-show-hierarchy-above))) (error "Quit")))) (defun org-get-location (buf help) "Let the user select a location in the Org-mode buffer BUF. This function uses a recursive edit. It returns the selected position or nil." (let (org-selected-point) (save-excursion (save-window-excursion (delete-other-windows) (switch-to-buffer (get-buffer-create "*org-goto*")) (with-output-to-temp-buffer "*Help*" (princ help)) (shrink-window-if-larger-than-buffer (get-buffer-window "*Help*")) (setq buffer-read-only nil) (erase-buffer) (insert-buffer buf) (let ((org-startup-truncated t) (org-startup-folded t) (org-startup-with-deadline-check nil)) (org-mode)) (setq buffer-read-only t) (if (boundp 'org-goto-start-pos) (goto-char org-goto-start-pos) (goto-char (point-min))) (org-beginning-of-line) (message "Select location and press RET") ;; now we make sure that during selection, ony very few keys work ;; and that it is impossible to switch to another window. (let ((gm (current-global-map)) (overriding-local-map org-goto-map)) (unwind-protect (progn (use-global-map org-goto-map) (recursive-edit)) (use-global-map gm))))) (kill-buffer "*org-goto*") org-selected-point)) ;; FIXME: It may not be a good idea to temper with the prefix argument... (defun org-goto-ret (&optional arg) "Finish org-goto by going to the new location." (interactive "P") (setq org-selected-point (point) current-prefix-arg arg) (throw 'exit nil)) (defun org-goto-left (&optional arg) "Finish org-goto by going to the new location." (interactive "P") (if (org-on-heading-p) (progn (beginning-of-line 1) (setq org-selected-point (point) current-prefix-arg (- (match-end 0) (match-beginning 0))) (throw 'exit nil)) (error "Not on a heading"))) (defun org-goto-right (&optional arg) "Finish org-goto by going to the new location." (interactive "P") (if (org-on-heading-p) (progn (outline-end-of-subtree) (or (eobp) (forward-char 1)) (setq org-selected-point (point) current-prefix-arg (- (match-end 0) (match-beginning 0))) (throw 'exit nil)) (error "Not on a heading"))) (defun org-goto-quit () "Finish org-goto without cursor motion." (interactive) (setq org-selected-point nil) (throw 'exit nil)) ;;; Promotion, Demotion, Inserting new headlines (defvar org-ignore-region nil "To temporary disable the active region.")  Carsten Dominik committed Jan 14, 2005 1826 (defun org-insert-heading (arg)  Richard M. Stallman committed Dec 06, 2004 1827  "Insert a new heading with same depth at point."  Carsten Dominik committed Jan 14, 2005 1828  (interactive "P")  Richard M. Stallman committed Dec 06, 2004 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337  (let* ((head (save-excursion (condition-case nil (org-back-to-heading) (error (outline-next-heading))) (prog1 (match-string 0) (funcall outline-level))))) (unless (bolp) (newline)) (insert head) (unless (eolp) (save-excursion (newline-and-indent))) (unless (equal (char-before) ?\ ) (insert " ")) (run-hooks 'org-insert-heading-hook))) (defun org-promote-subtree (&optional arg) "Promote the entire subtree. See also org-promote'." (interactive "P") (org-map-tree 'org-promote)) (defun org-demote-subtree (&optional arg) "Demote the entire subtree. See org-demote'. See also org-promote'." (interactive "P") (org-map-tree 'org-demote)) (defun org-do-promote (&optional arg) "Promote the current heading higher up the tree. If the region is active in transient-mark-mode, promote all headings in the region." (interactive "P") (save-excursion (if (org-region-active-p) (org-map-region 'org-promote (region-beginning) (region-end)) (org-promote))) (org-fix-position-after-promote)) (defun org-do-demote (&optional arg) "Demote the current heading lower down the tree. If the region is active in transient-mark-mode, demote all headings in the region." (interactive "P") (save-excursion (if (org-region-active-p) (org-map-region 'org-demote (region-beginning) (region-end)) (org-demote))) (org-fix-position-after-promote)) (defun org-fix-position-after-promote () "Make sure that after pro/demotion cursor position is right." (and (equal (char-after) ?\ ) (equal (char-before) ?*) (forward-char 1))) (defun org-promote () "Promote the current heading higher up the tree. If the region is active in transient-mark-mode, promote all headings in the region." (org-back-to-heading t) (let* ((level (save-match-data (funcall outline-level))) (up-head (make-string (1- level) ?*))) (if (= level 1) (error "Cannot promote to level 0. UNDO to recover.")) (replace-match up-head nil t) (if org-adapt-indentation (org-fixup-indentation "^ " "" "^ ?\\S-")))) (defun org-demote () "Demote the current heading lower down the tree. If the region is active in transient-mark-mode, demote all headings in the region." (org-back-to-heading t) (let* ((level (save-match-data (funcall outline-level))) (down-head (make-string (1+ level) ?*))) (replace-match down-head nil t) (if org-adapt-indentation (org-fixup-indentation "^ " " " "^\\S-")))) (defun org-map-tree (fun) "Call FUN for every heading underneath the current one." (org-back-to-heading) (let ((level (outline-level))) (save-excursion (funcall fun) (while (and (progn (outline-next-heading) (> (funcall outline-level) level)) (not (eobp))) (funcall fun))))) (defun org-map-region (fun beg end) "Call FUN for every heading between BEG and END." (let ((org-ignore-region t)) (save-excursion (setq end (copy-marker end)) (goto-char beg) ;; (if (fboundp 'deactivate-mark) (deactivate-mark)) ;; (if (fboundp 'zmacs-deactivate-region) (zmacs-deactivate-region)) (if (and (re-search-forward (concat "^" outline-regexp) nil t) (< (point) end)) (funcall fun)) (while (and (progn (outline-next-heading) (< (point) end)) (not (eobp))) (funcall fun))))) (defun org-fixup-indentation (from to prohibit) "Change the indentation in the current entry by re-replacing FROM with TO. However, if the regexp PROHIBIT matches at all, don't do anything. This is being used to change indentation along with the length of the heading marker. But if there are any lines which are not indented, nothing is changed at all." (save-excursion (let ((end (save-excursion (outline-next-heading) (point-marker)))) (unless (save-excursion (re-search-forward prohibit end t)) (while (re-search-forward from end t) (replace-match to) (beginning-of-line 2))) (move-marker end nil)))) ;;; Vertical tree motion, cutting and pasting of subtrees (defun org-move-subtree-up (&optional arg) "Move the current subtree up past ARG headlines of the same level." (interactive "p") (org-move-subtree-down (- (prefix-numeric-value arg)))) (defun org-move-subtree-down (&optional arg) "Move the current subtree down past ARG headlines of the same level." (interactive "p") (setq arg (prefix-numeric-value arg)) (let ((movfunc (if (> arg 0) 'outline-get-next-sibling 'outline-get-last-sibling)) (ins-point (make-marker)) (cnt (abs arg)) beg end txt folded) ;; Select the tree (org-back-to-heading) (setq beg (point)) (save-match-data (save-excursion (outline-end-of-heading) (setq folded (org-invisible-p))) (outline-end-of-subtree)) (if (equal (char-after) ?\n) (forward-char 1)) (setq end (point)) ;; Find insertion point, with error handling (goto-char beg) (while (> cnt 0) (or (and (funcall movfunc) (looking-at outline-regexp)) (progn (goto-char beg) (error "Cannot move past superior level or buffer limit"))) (setq cnt (1- cnt))) (if (> arg 0) ;; Moving forward - still need to move over subtree (progn (outline-end-of-subtree) (if (equal (char-after) ?\n) (forward-char 1)))) (move-marker ins-point (point)) (setq txt (buffer-substring beg end)) (delete-region beg end) (insert txt) (goto-char ins-point) (if folded (hide-subtree)) (move-marker ins-point nil))) (defvar org-subtree-clip "" "Clipboard for cut and paste of subtrees. This is actually only a cpoy of the kill, because we use the normal kill ring. We need it to check if the kill was created by org-copy-subtree'.") (defvar org-subtree-clip-folded nil "Was the last copied suptree folded? This is used to fold the tree back after pasting.") (defun org-cut-subtree (&optional arg) "Cut the current subtree into the clipboard. This is a short-hand for marking the subtree and then cutting it." (interactive "p") (org-copy-subtree arg 'cut)) (defun org-copy-subtree (&optional arg cut) "Cut the current subtree into the clipboard. This is a short-hand for marking the subtree and then copying it. If CUT is non nil, actually cur the subtree." (interactive "p") (let (beg end folded) (org-back-to-heading) (setq beg (point)) (save-match-data (save-excursion (outline-end-of-heading) (setq folded (org-invisible-p))) (outline-end-of-subtree)) (if (equal (char-after) ?\n) (forward-char 1)) (setq end (point)) (goto-char beg) (when (> end beg) (setq org-subtree-clip-folded folded) (if cut (kill-region beg end) (copy-region-as-kill beg end)) (setq org-subtree-clip (current-kill 0)) (message "%s: Subtree with %d characters" (if cut "Cut" "Copied") (length org-subtree-clip))))) (defun org-paste-subtree (&optional level tree) "Paste the clipboard as a subtree, with modification of headline level. The entire subtree is promoted or demoted in order to match a new headline level. By default, the new level is derived from the visible headings before and after the insertion point, and taken to be the inferior headline level of the two. So if the previous visible heading is level 3 and the next is level 4 (or vice versa), level 4 will be used for insertion. This makes sure that the subtree remains an independent subtree and does not swallow low level entries. You can also force a different level, either by using a numeric prefix argument, or by inserting the heading marker by hand. For example, if the cursor is after \"*****\", then the tree will be shifted to level 5. If you want to insert the tree as is, just use \\[yank]. If optional TREE is given, use this text instead of the kill ring." (interactive "P") (unless (org-kill-is-subtree-p tree) (error (substitute-command-keys "The kill is not a (set of) tree(s) - please use \\[yank] to yank anyway"))) (let* ((txt (or tree (current-kill 0))) (^re (concat "^\$$" outline-regexp "\$$")) (re (concat "\$$" outline-regexp "\$$")) (^re_ (concat "\$$" outline-regexp "\$$[ \t]*")) (old-level (if (string-match ^re txt) (- (match-end 0) (match-beginning 0)) -1)) (force-level (cond (level (prefix-numeric-value level)) ((string-match ^re_ (buffer-substring (point-at-bol) (point))) (- (match-end 0) (match-beginning 0))) (t nil))) (prevous-level (save-excursion (outline-previous-visible-heading 1) (if (looking-at re) (- (match-end 0) (match-beginning 0)) 1))) (next-level (save-excursion (outline-next-visible-heading 1) (if (looking-at re) (- (match-end 0) (match-beginning 0)) 1))) (new-level (or force-level (max prevous-level next-level))) (shift (if (or (= old-level -1) (= new-level -1) (= old-level new-level)) 0 (- new-level old-level))) (shift1 shift) (delta (if (> shift 0) -1 1)) (func (if (> shift 0) 'org-demote 'org-promote)) beg end) ;; Remove the forces level indicator (if force-level (delete-region (point-at-bol) (point))) ;; Make sure we start at the beginning of an empty line (if (not (bolp)) (insert "\n")) (if (not (looking-at "[ \t]*")) (progn (insert "\n") (backward-char 1))) ;; Paste (setq beg (point)) (insert txt) (setq end (point)) (goto-char beg) ;; Shift if necessary (if (= shift 0) (message "Pasted at level %d, without shift" new-level) (save-restriction (narrow-to-region beg end) (while (not (= shift 0)) (org-map-region func (point-min) (point-max)) (setq shift (+ delta shift))) (goto-char (point-min)) (message "Pasted at level %d, with shift by %d levels" new-level shift1))) (if (and (eq org-subtree-clip (current-kill 0)) org-subtree-clip-folded) ;; The tree was folded before it was killed/copied (hide-subtree)))) (defun org-kill-is-subtree-p (&optional txt) "Check if the current kill is an outline subtree, or a set of trees. Returns nil if kill does not start with a headline, or if the first headline level is not the largest headline level in the tree. So this will actually acceept several entries of equal levels as well, which is OK for org-paste-subtree'. If optional TXT is given, check this string instead of the current kill." (let* ((kill (or txt (current-kill 0) "")) (start-level (and (string-match (concat "\\" outline-regexp) kill) (- (match-end 0) (match-beginning 0)))) (re (concat "^" outline-regexp)) (start 1)) (if (not start-level) nil ;; does not even start with a heading (catch 'exit (while (setq start (string-match re kill (1+ start))) (if (< (- (match-end 0) (match-beginning 0)) start-level) (throw 'exit nil))) t)))) ;;; Completion (defun org-complete (&optional arg) "Perform completion on word at point. At the beginning of a headline, this completes TODO keywords as given in org-todo-keywords'. If the current word is preceeded by a backslash, completes the TeX symbols that are supported for HTML support. If the current word is preceeded by \"#+\", completes special words for setting file options. At all other locations, this simply calls ispell-complete-word'." (interactive "P") (catch 'exit (let* ((end (point)) (beg (save-excursion (if (equal (char-before (point)) ?\ ) (backward-char 1)) (skip-chars-backward "a-zA-Z0-9_:") (point))) (texp (equal (char-before beg) ?\\)) (opt (equal (buffer-substring (max (point-at-bol) (- beg 2)) beg) "#+")) (pattern (buffer-substring-no-properties beg end)) (completion-ignore-case opt) (type nil) (table (cond (opt (setq type :opt) (mapcar (lambda (x) (string-match "^#\\+\$$\\([A-Z_]+:?\$$.*\\)" x) (cons (match-string 2 x) (match-string 1 x))) (org-split-string (org-get-current-options) "\n"))) (texp (setq type :tex) org-html-entities) ((string-match "\\\\*+[ \t]*\\'" (buffer-substring (point-at-bol) beg)) (setq type :todo) (mapcar 'list org-todo-keywords)) (t (progn (ispell-complete-word arg) (throw 'exit nil))))) (completion (try-completion pattern table))) (cond ((eq completion t) (if (equal type :opt) (insert (substring (cdr (assoc (upcase pattern) table)) (length pattern))))) ((null completion) (message "Can't find completion for \"%s\"" pattern) (ding)) ((not (string= pattern completion)) (delete-region beg end) (if (string-match " +" completion) (setq completion (replace-match "" t t completion))) (insert completion) (if (get-buffer-window "*Completions*") (delete-window (get-buffer-window "*Completions*"))) (if (and (eq type :todo) (assoc completion table)) (insert " ")) (if (and (equal type :opt) (assoc completion table)) (message (substitute-command-keys "Press \\[org-complete] again to insert example settings")))) (t (message "Making completion list...") (let ((list (sort (all-completions pattern table) 'string<))) (with-output-to-temp-buffer "*Completions*" (display-completion-list list))) (message "Making completion list...%s" "done")))))) ;;; Comments, TODO and DEADLINE (defun org-toggle-comment () "Change the COMMENT state of an entry." (interactive) (save-excursion (org-back-to-heading) (if (looking-at (concat outline-regexp "\$$+\\<" org-comment-string "\\>\$$")) (replace-match "" t t nil 1) (if (looking-at outline-regexp) (progn (goto-char (match-end 0)) (insert " " org-comment-string)))))) (defun org-todo (&optional arg) "Change the TODO state of an item. The state of an item is given by a keyword at the start of the heading, like *** TODO Write paper *** DONE Call mom The different keywords are specified in the variable org-todo-keywords'. By default the available states are \"TODO\" and \"DONE\". So for this example: when the item starts with TODO, it is changed to DONE. When it starts with DONE, the DONE is removed. And when neither TODO nor DONE are present, add TODO at the beginning of the heading. With prefix arg, use completion to determined the new state. With numeric prefix arg, switch to that state." (interactive "P") (save-excursion (org-back-to-heading) (if (looking-at outline-regexp) (goto-char (match-end 0))) (or (looking-at (concat " +" org-todo-regexp " *")) (looking-at " *")) (let* ((this (match-string 1)) (completion-ignore-case t) (member (member this org-todo-keywords)) (tail (cdr member)) (state (cond ((equal arg '(4)) ;; Read a state with completion (completing-read "State: " (mapcar (lambda(x) (list x)) org-todo-keywords) nil t)) (arg ;; user requests a specific state (nth (1- (prefix-numeric-value arg)) org-todo-keywords)) ((null member) (car org-todo-keywords)) ((null tail) nil) ;; -> first entry ((eq org-todo-interpretation 'sequence) (car tail)) ((memq org-todo-interpretation '(type priority)) (if (eq this-command last-command) (car tail) (if (> (length tail) 0) org-done-string nil))) (t nil))) (next (if state (concat " " state " ") " "))) (replace-match next t t) (run-hooks 'org-after-todo-state-change-hook))) ;; Fixup cursor location if close to the keyword (if (and (outline-on-heading-p) (not (bolp)) (save-excursion (goto-char (point-at-bol)) (looking-at org-todo-line-regexp)) (< (point) (+ 2 (or (match-end 2) (match-end 1))))) (progn (goto-char (or (match-end 2) (match-end 1))) (just-one-space)))) (defun org-show-todo-tree (arg) "Make a compact tree which shows all headlines marked with TODO. The tree will show the lines where the regexp matches, and all higher headlines above the match." (interactive "P") (let ((case-fold-search nil) (kwd-re (if arg org-todo-regexp org-not-done-regexp))) (message "%d TODO entries found" (org-occur (concat "^" outline-regexp " +" kwd-re ))))) (defun org-deadline () "Insert the DEADLINE: string to make a deadline. A timestamp is also inserted - use \\[org-timestamp-up] and \\[org-timestamp-down] to modify it to the correct date." (interactive) (insert org-deadline-string " " (format-time-string (car org-time-stamp-formats) (org-read-date nil 'to-time))) (message (substitute-command-keys "Use \\[org-timestamp-up-day] and \\[org-timestamp-down-day] to change the date."))) (defun org-schedule () "Insert the SCHEDULED: string to schedule a TODO item. A timestamp is also inserted - use \\[org-timestamp-up] and \\[org-timestamp-down] to modify it to the correct date." (interactive) (insert org-scheduled-string " " (format-time-string (car org-time-stamp-formats) (org-read-date nil 'to-time))) (message (substitute-command-keys "Use \\[org-timestamp-up-day] and \\[org-timestamp-down-day] to change the date."))) (defun org-occur (regexp &optional callback) "Make a compact tree which shows all matches of REGEXP. The tree will show the lines where the regexp matches, and all higher headlines above the match. It will also show the heading after the match, to make sure editing the matching entry is easy. if CALLBACK is non-nil, it is a function which is called to confirm that the match should indeed be shown." (interactive "sRegexp: ") (setq regexp (org-check-occur-regexp regexp)) (let ((cnt 0)) (save-excursion (goto-char (point-min)) (hide-sublevels 1) (while (re-search-forward regexp nil t) (when (or (not callback) (funcall callback)) (setq cnt (1+ cnt)) (org-show-hierarchy-above)))) (if (interactive-p) (message "%d match(es) for regexp %s" cnt regexp)) cnt)) (defun org-show-hierarchy-above () "Make sure point and the headings hierarchy above is visible." (if (org-on-heading-p t) (org-flag-heading nil) ; only show the heading (org-show-hidden-entry)) ; show entire entry (save-excursion  Carsten Dominik committed Jan 14, 2005 2338 2339  (and org-show-following-heading (outline-next-heading)  Richard M. Stallman committed Dec 06, 2004 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421  (org-flag-heading nil))) ; show the next heading (save-excursion ; show all higher headings (while (condition-case nil (progn (org-up-heading-all 1) t) (error nil)) (org-flag-heading nil)))) ;;; Priorities (defvar org-priority-regexp ".*?\$$\\[#\\([A-Z]\$$\$ ?\\)" "Regular expression matching the priority indicator.") (defun org-priority-up () "Increase the priority of the current item." (interactive) (org-priority 'up)) (defun org-priority-down () "Decrease the priority of the current item." (interactive) (org-priority 'down)) (defun org-priority (&optional action) "Change the priority of an item by ARG. ACTION can be set, up, or down." (interactive) (setq action (or action 'set)) (let (current new news have remove) (save-excursion (org-back-to-heading) (if (looking-at org-priority-regexp) (setq current (string-to-char (match-string 2)) have t) (setq current org-default-priority)) (cond ((eq action 'set) (message (format "Priority A-%c, SPC to remove: " org-lowest-priority)) (setq new (read-char-exclusive)) (if (equal new ?\ ) (setq remove t))) ((eq action 'up) (setq new (1- current))) ((eq action 'down) (setq new (1+ current))) (t (error "Illegal ection"))) (setq new (min (max ?A (upcase new)) org-lowest-priority)) (setq news (format "%c" new)) (if have (if remove (replace-match "" t t nil 1) (replace-match news t t nil 2)) (looking-at org-todo-line-regexp) (if (match-end 2) (progn (goto-char (match-end 2)) (insert " [#" news "]")) (goto-char (match-beginning 3)) (insert "[#" news "] ")))) (if remove (message "Priority removed") (message "Priority of current item set to %s" news)))) (defun org-get-priority (s) "Find priority cookie and return priority." (save-match-data (if (not (string-match org-priority-regexp s)) (* 1000 (- org-lowest-priority org-default-priority)) (* 1000 (- org-lowest-priority (string-to-char (match-string 2 s))))))) ;;; Timestamps (defvar org-last-changed-timestamp nil) (defun org-time-stamp (arg) "Prompt for a date/time and insert a time stamp. If the user specifies a time like HH:MM, or if this command is called with a prefix argument, the time stamp will contain date and time. Otherwise, only the date will be included. All parts of a date not specified by the user will be filled in from the current date/time. So if you press just return without typing anything, the time stamp will represent the current date/time. If there is already a timestamp  Carsten Dominik committed Jan 14, 2005 2422 at the cursor, it will be modified."  Richard M. Stallman committed Dec 06, 2004 2423 2424 2425 2426 2427 2428