comparison lisp/textmodes/org.el @ 71310:0d8984127630

(org-agenda-mode-map): Add bindings for clocking functions. (org-agenda-clock-in, org-check-running-clock) (org-clock-out-if-current, org-remove-clock-overlays) (org-put-clock-overlay): New functions. (org-clock-marker, org-clock-file-total-minutes) (org-clock-overlays): New variables (org-clock-display, org-clock-sum, org-clock-cancel) (org-clock-out, org-clock-in): New commands. (org-export): New function. (org-emph-re): New constant. (org-set-emph-re, org-do-emphasis-faces): New functions. (org-emphasis-regexp-components, org-emphasis-alist): New options. (org-set-font-lock-defaults): Call `org-do-emphasis-faces'. (org-export-html-convert-emphasize): Use the configurable emphasis. (org-cleaned-string-for-export): Make multiline emphasis visible to the exporter. New optional argument PARAMETERS. (org-export-as-html): Specify :emph-multiline parameter to `org-cleaned-string-for-export'.
author Carsten Dominik <dominik@science.uva.nl>
date Sat, 10 Jun 2006 14:15:25 +0000
parents 11ad1dbc7d45
children 9853142939b3 138027c8c982
comparison
equal deleted inserted replaced
71309:ac498715ccc8 71310:0d8984127630
3 ;; Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. 3 ;; Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
4 ;; 4 ;;
5 ;; Author: Carsten Dominik <dominik at science dot uva dot nl> 5 ;; Author: Carsten Dominik <dominik at science dot uva dot nl>
6 ;; Keywords: outlines, hypermedia, calendar, wp 6 ;; Keywords: outlines, hypermedia, calendar, wp
7 ;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/ 7 ;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/
8 ;; Version: 4.36 8 ;; Version: 4.36b
9 ;; 9 ;;
10 ;; This file is part of GNU Emacs. 10 ;; This file is part of GNU Emacs.
11 ;; 11 ;;
12 ;; GNU Emacs is free software; you can redistribute it and/or modify 12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by 13 ;; it under the terms of the GNU General Public License as published by
88 ;; excellent reference card made by Philip Rooke. This card can be found 88 ;; excellent reference card made by Philip Rooke. This card can be found
89 ;; in the etc/ directory of Emacs 22. 89 ;; in the etc/ directory of Emacs 22.
90 ;; 90 ;;
91 ;; Recent changes 91 ;; Recent changes
92 ;; -------------- 92 ;; --------------
93 ;; Version 4.37
94 ;; - Clock-feature for measuring time spent on specific items.
95 ;; - Improved emphasizing allows configuration and stacking.
96 ;;
93 ;; Version 4.36 97 ;; Version 4.36
94 ;; - Improved indentation of ASCII export, when headlines become items. 98 ;; - Improved indentation of ASCII export, when headlines become items.
95 ;; - Handling of 12am and 12pm fixed. Times beyond 24:00 can be used 99 ;; - Handling of 12am and 12pm fixed. Times beyond 24:00 can be used
96 ;; and will not lead to conflicts. 100 ;; and will not lead to conflicts.
97 ;; - Support for mutually exclusive TAGS with the fast tags interface. 101 ;; - Support for mutually exclusive TAGS with the fast tags interface.
120 ;; - `org-export-publishing-directory' can be an alist, with different 124 ;; - `org-export-publishing-directory' can be an alist, with different
121 ;; directories for different export types. 125 ;; directories for different export types.
122 ;; - All context-sensitive commands use `call-interactively' to dispatch. 126 ;; - All context-sensitive commands use `call-interactively' to dispatch.
123 ;; - `org-confirm-shell-links' renamed to `org-confirm-shell-link-function'. 127 ;; - `org-confirm-shell-links' renamed to `org-confirm-shell-link-function'.
124 ;; - Bug fixes. 128 ;; - Bug fixes.
125 ;; 129 ;;
126 ;; Version 4.31 130 ;; Version 4.31
127 ;; - Bug fixes. 131 ;; - Bug fixes.
128 ;; 132 ;;
129 ;; Version 4.30 133 ;; Version 4.30
130 ;; - Modified installation: Autoloads have been collected in org-install.el. 134 ;; - Modified installation: Autoloads have been collected in org-install.el.
161 ;; entries that are sublevels of another TODO entry. 165 ;; entries that are sublevels of another TODO entry.
162 ;; 166 ;;
163 ;; 167 ;;
164 ;;; Code: 168 ;;; Code:
165 169
166 (eval-when-compile 170 (eval-when-compile
167 (require 'cl) 171 (require 'cl)
168 (require 'calendar)) 172 (require 'calendar))
169 (require 'outline) 173 (require 'outline)
170 (require 'time-date) 174 (require 'time-date)
171 (require 'easymenu) 175 (require 'easymenu)
172 176
173 ;;; Customization variables 177 ;;; Customization variables
174 178
175 (defvar org-version "4.36" 179 (defvar org-version "4.36b"
176 "The version number of the file org.el.") 180 "The version number of the file org.el.")
177 (defun org-version () 181 (defun org-version ()
178 (interactive) 182 (interactive)
179 (message "Org-mode version %s" org-version)) 183 (message "Org-mode version %s" org-version))
180 184
328 :group 'org-keywords 332 :group 'org-keywords
329 :type 'string) 333 :type 'string)
330 334
331 (defcustom org-closed-string "CLOSED:" 335 (defcustom org-closed-string "CLOSED:"
332 "String used as the prefix for timestamps logging closing a TODO entry." 336 "String used as the prefix for timestamps logging closing a TODO entry."
337 :group 'org-keywords
338 :type 'string)
339
340 (defcustom org-clock-string "CLOCK:"
341 "String used as prefix for timestamps clocking work hours on an item."
333 :group 'org-keywords 342 :group 'org-keywords
334 :type 'string) 343 :type 'string)
335 344
336 (defcustom org-comment-string "COMMENT" 345 (defcustom org-comment-string "COMMENT"
337 "Entries starting with this keyword will never be exported. 346 "Entries starting with this keyword will never be exported.
2132 "Non-nil means fontify *bold*, /italic/ and _underlined_ text. 2141 "Non-nil means fontify *bold*, /italic/ and _underlined_ text.
2133 Changing this variable requires a restart of Emacs to take effect." 2142 Changing this variable requires a restart of Emacs to take effect."
2134 :group 'org-font-lock 2143 :group 'org-font-lock
2135 :type 'boolean) 2144 :type 'boolean)
2136 2145
2146 (defvar org-emph-re nil
2147 "Regular expression for matching emphasis.")
2148 (defvar org-emphasis-regexp-components) ; defined just below
2149 (defvar org-emphasis-alist) ; defined just below
2150 (defun org-set-emph-re (var val)
2151 "Set variable and compute the emphasis regular expression."
2152 (set var val)
2153 (when (and (boundp 'org-emphasis-alist)
2154 (boundp 'org-emphasis-regexp-components)
2155 org-emphasis-alist org-emphasis-regexp-components)
2156 (let* ((e org-emphasis-regexp-components)
2157 (pre (car e))
2158 (post (nth 1 e))
2159 (border (nth 2 e))
2160 (body (nth 3 e))
2161 (nl (nth 4 e))
2162 (stacked (nth 5 e))
2163 (body1 (concat body "*?"))
2164 (markers (mapconcat 'car org-emphasis-alist "")))
2165 ;; make sure special characters appear at the right position in the class
2166 (if (string-match "\\^" markers)
2167 (setq markers (concat (replace-match "" t t markers) "^")))
2168 (if (string-match "-" markers)
2169 (setq markers (concat (replace-match "" t t markers) "-")))
2170 (while (>= (setq nl (1- nl)) 0) (setq body1 (concat body1 "\n?" body "*?")))
2171 ;; Make the regexp
2172 (setq org-emph-re
2173 (concat "\\([" pre (if stacked markers) "]\\|^\\)"
2174 "\\("
2175 "\\([" markers "]\\)"
2176 "\\("
2177 "[^" border markers "]"
2178 body1
2179 "[^" border markers "]"
2180 "\\)"
2181 "\\3\\)"
2182 "\\([" post (if stacked markers) "]\\|$\\)")))))
2183
2184 (defcustom org-emphasis-regexp-components
2185 '(" \t(" " \t.,?;:'\")" " \t\r\n,." "." 1 nil)
2186 "Components used to build the reqular expression for emphasis.
2187 This is a list with 6 entries. Terminology: In an emphasis string
2188 like \" *strong word* \", we call the initial space PREMATCH, the final
2189 space POSTMATCH, the stars MARKERS, \"s\" and \"d\" are BORDER characters
2190 and \"trong wor\" is the body. The different components in this variable
2191 specify what is allowed/forbidden in each part:
2192
2193 pre Chars allowed as prematch. Beginning of line will be allowed too.
2194 post Chars allowed as postmatch. End of line will be allowed too.
2195 border The chars *forbidden* as border characters. In addition to the
2196 characters given here, all marker characters are forbidden too.
2197 body-regexp A regexp like \".\" to match a body character. Don't use
2198 non-shy groups here, and don't allow newline here.
2199 newline The maximum number of newlines allowed in an emphasis exp.
2200 stacked Non-nil means, allow stacked styles. This works only in HTML
2201 export. When this is set, all marker characters (as given in
2202 `org-emphasis-alist') will be allowed as pre/post, aiding
2203 inside-out matching.
2204 Use customize to modify this, or restart emacs after changing it."
2205 :group 'org-fixme
2206 :set 'org-set-emph-re
2207 :type '(list
2208 (sexp :tag "Allowed chars in pre ")
2209 (sexp :tag "Allowed chars in post ")
2210 (sexp :tag "Forbidden chars in border ")
2211 (sexp :tag "Regexp for body ")
2212 (integer :tag "number of newlines allowed")
2213 (boolean :tag "Stacking allowed ")))
2214
2215 (defcustom org-emphasis-alist
2216 '(("*" bold "<b>" "</b>")
2217 ("/" italic "<i>" "</i>")
2218 ("_" underline "<u>" "</u>")
2219 ("=" shadow "<code>" "</code>"))
2220 "Special syntax for emphasised text.
2221 Text starting and ending with a special character will be emphasized, for
2222 example *bold*, _underlined_ and /italic/. This variable sets the marker
2223 characters, the face to bbe used by font-lock for highlighting in Org-mode
2224 emacs buffers, and the HTML tags to be used for this.
2225 Use customize to modify this, or restart emacs after changing it."
2226 :group 'org-fixme
2227 :set 'org-set-emph-re
2228 :type '(repeat
2229 (list
2230 (string :tag "Marker character")
2231 (face :tag "Font-lock-face")
2232 (string :tag "HTML start tag")
2233 (string :tag "HTML end tag"))))
2234
2137 (defgroup org-faces nil 2235 (defgroup org-faces nil
2138 "Faces in Org-mode." 2236 "Faces in Org-mode."
2139 :tag "Org Faces" 2237 :tag "Org Faces"
2140 :group 'org-font-lock) 2238 :group 'org-font-lock)
2141 2239
2372 '(org-level-1 org-level-2 org-level-3 org-level-4 2470 '(org-level-1 org-level-2 org-level-3 org-level-4
2373 org-level-5 org-level-6 org-level-7 org-level-8 2471 org-level-5 org-level-6 org-level-7 org-level-8
2374 )) 2472 ))
2375 (defconst org-n-levels (length org-level-faces)) 2473 (defconst org-n-levels (length org-level-faces))
2376 2474
2377 (defconst org-bold-re
2378 (if (featurep 'xemacs)
2379 "\\([ ]\\|^\\)\\(\\*\\(\\w[a-zA-Z0-9-_ ]*?\\w\\)\\*\\)\\([ ,.]\\|$\\)"
2380 "\\([ ]\\|^\\)\\(\\*\\(\\w[[:word:] -_]*?\\w\\)\\*\\)\\([ ,.]\\|$\\)")
2381 "Regular expression for bold emphasis.")
2382 (defconst org-italic-re
2383 (if (featurep 'xemacs)
2384 "\\([ ]\\|^\\)\\(/\\(\\w[a-zA-Z0-9-_ ]*?\\w\\)/\\)\\([ ,.]\\|$\\)"
2385 "\\([ ]\\|^\\)\\(/\\(\\w[[:word:] -_]*?\\w\\)/\\)\\([ ,.]\\|$\\)")
2386 "Regular expression for italic emphasis.")
2387 (defconst org-underline-re
2388 (if (featurep 'xemacs)
2389 "\\([ ]\\|^\\)\\(_\\(\\w[a-zA-Z0-9-_ ]*?\\w\\)_\\)\\([ ,.]\\|$\\)"
2390 "\\([ ]\\|^\\)\\(_\\(\\w[[:word:] -_]*?\\w\\)_\\)\\([ ,.]\\|$\\)")
2391 "Regular expression for underline emphasis.")
2392 2475
2393 ;; Variables for pre-computed regular expressions, all buffer local 2476 ;; Variables for pre-computed regular expressions, all buffer local
2394 (defvar org-done-string nil 2477 (defvar org-done-string nil
2395 "The last string in `org-todo-keywords', indicating an item is DONE.") 2478 "The last string in `org-todo-keywords', indicating an item is DONE.")
2396 (make-variable-buffer-local 'org-done-string) 2479 (make-variable-buffer-local 'org-done-string)
2580 org-closed-time-regexp 2663 org-closed-time-regexp
2581 (concat "\\<" org-closed-string " *\\[\\([^]]+\\)\\]") 2664 (concat "\\<" org-closed-string " *\\[\\([^]]+\\)\\]")
2582 org-keyword-time-regexp 2665 org-keyword-time-regexp
2583 (concat "\\<\\(" org-scheduled-string 2666 (concat "\\<\\(" org-scheduled-string
2584 "\\|" org-deadline-string 2667 "\\|" org-deadline-string
2585 "\\|" org-closed-string "\\)" 2668 "\\|" org-closed-string
2669 "\\|" org-clock-string "\\)"
2586 " *[[<]\\([^]>]+\\)[]>]") 2670 " *[[<]\\([^]>]+\\)[]>]")
2587 org-maybe-keyword-time-regexp 2671 org-maybe-keyword-time-regexp
2588 (concat "\\(\\<\\(" org-scheduled-string 2672 (concat "\\(\\<\\(" org-scheduled-string
2589 "\\|" org-deadline-string 2673 "\\|" org-deadline-string
2590 "\\|" org-closed-string "\\)\\)?" 2674 "\\|" org-closed-string
2675 "\\|" org-clock-string "\\)\\)?"
2591 " *\\([[<][0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}[^]\r\n>]*?[]>]\\)")) 2676 " *\\([[<][0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}[^]\r\n>]*?[]>]\\)"))
2592 2677
2593 (org-set-font-lock-defaults))) 2678 (org-set-font-lock-defaults)))
2594 2679
2595 ;; Tell the compiler about dynamically scoped variables, 2680 ;; Tell the compiler about dynamically scoped variables,
2607 (defvar org-ts-what) ; dynamically scoped parameter 2692 (defvar org-ts-what) ; dynamically scoped parameter
2608 (defvar mark-active) ; Emacs only, not available in XEmacs. 2693 (defvar mark-active) ; Emacs only, not available in XEmacs.
2609 (defvar timecnt) ; dynamically scoped parameter 2694 (defvar timecnt) ; dynamically scoped parameter
2610 (defvar levels-open) ; dynamically scoped parameter 2695 (defvar levels-open) ; dynamically scoped parameter
2611 (defvar entry) ; dynamically scoped parameter 2696 (defvar entry) ; dynamically scoped parameter
2697 (defvar state) ; dynamically scoped into `org-after-todo-state-change-hook'
2612 (defvar date) ; dynamically scoped parameter 2698 (defvar date) ; dynamically scoped parameter
2613 (defvar description) ; dynamically scoped parameter 2699 (defvar description) ; dynamically scoped parameter
2614 (defvar ans1) ; dynamically scoped parameter 2700 (defvar ans1) ; dynamically scoped parameter
2615 (defvar ans2) ; dynamically scoped parameter 2701 (defvar ans2) ; dynamically scoped parameter
2616 (defvar starting-day) ; local variable 2702 (defvar starting-day) ; local variable
2638 (defvar Info-current-file) ; from info.el 2724 (defvar Info-current-file) ; from info.el
2639 (defvar Info-current-node) ; from info.el 2725 (defvar Info-current-node) ; from info.el
2640 2726
2641 ;;; Define the mode 2727 ;;; Define the mode
2642 2728
2643 (defvar org-mode-map 2729 (defvar org-mode-map
2644 (if (and (not (keymapp outline-mode-map)) (featurep 'allout)) 2730 (if (and (not (keymapp outline-mode-map)) (featurep 'allout))
2645 (error "Conflict with outdated version of allout.el. Load org.el before allout.el, or ugrade to newer allout, for example by switching to Emacs 22.") 2731 (error "Conflict with outdated version of allout.el. Load org.el before allout.el, or ugrade to newer allout, for example by switching to Emacs 22.")
2646 (copy-keymap outline-mode-map)) 2732 (copy-keymap outline-mode-map))
2647 "Keymap for Org-mode.") 2733 "Keymap for Org-mode.")
2648 2734
2709 ;;(setq outline-regexp "\\(?:\\*+\\|[ \t]*\\(?:[-+*]\\|[0-9]+[.)]\\) \\)") 2795 ;;(setq outline-regexp "\\(?:\\*+\\|[ \t]*\\(?:[-+*]\\|[0-9]+[.)]\\) \\)")
2710 (setq outline-level 'org-outline-level) 2796 (setq outline-level 'org-outline-level)
2711 (when (and org-ellipsis (stringp org-ellipsis)) 2797 (when (and org-ellipsis (stringp org-ellipsis))
2712 (unless org-display-table 2798 (unless org-display-table
2713 (setq org-display-table (make-display-table))) 2799 (setq org-display-table (make-display-table)))
2714 (set-display-table-slot org-display-table 2800 (set-display-table-slot org-display-table
2715 4 (string-to-vector org-ellipsis)) 2801 4 (string-to-vector org-ellipsis))
2716 (setq buffer-display-table org-display-table)) 2802 (setq buffer-display-table org-display-table))
2717 (org-set-regexps-and-options) 2803 (org-set-regexps-and-options)
2804 (modify-syntax-entry ?# "<")
2718 (if org-startup-truncated (setq truncate-lines t)) 2805 (if org-startup-truncated (setq truncate-lines t))
2719 (set (make-local-variable 'font-lock-unfontify-region-function) 2806 (set (make-local-variable 'font-lock-unfontify-region-function)
2720 'org-unfontify-region) 2807 'org-unfontify-region)
2721 ;; Activate before-change-function 2808 ;; Activate before-change-function
2722 (set (make-local-variable 'org-table-may-need-update) t) 2809 (set (make-local-variable 'org-table-may-need-update) t)
2723 (org-add-hook 'before-change-functions 'org-before-change-function nil 2810 (org-add-hook 'before-change-functions 'org-before-change-function nil
2724 'local) 2811 'local)
2812 ;; Check for running clock before killing a buffer
2813 (org-add-hook 'kill-buffer-hook 'org-check-running-clock nil 'local)
2725 ;; Paragraphs and auto-filling 2814 ;; Paragraphs and auto-filling
2726 (org-set-autofill-regexps) 2815 (org-set-autofill-regexps)
2727 (org-update-radio-target-regexp) 2816 (org-update-radio-target-regexp)
2728 ;; Settings for Calc embedded mode 2817 ;; Settings for Calc embedded mode
2729 (set (make-local-variable 'calc-embedded-open-formula) "|\\|\n") 2818 (set (make-local-variable 'calc-embedded-open-formula) "|\\|\n")
2791 (require 'font-lock) 2880 (require 'font-lock)
2792 2881
2793 (defconst org-non-link-chars "]\t\n\r<>") 2882 (defconst org-non-link-chars "]\t\n\r<>")
2794 (defconst org-link-types '("https?" "ftp" "mailto" "file" "news" "bbdb" "vm" 2883 (defconst org-link-types '("https?" "ftp" "mailto" "file" "news" "bbdb" "vm"
2795 "wl" "mhe" "rmail" "gnus" "shell" "info" "elisp")) 2884 "wl" "mhe" "rmail" "gnus" "shell" "info" "elisp"))
2796 (defconst org-link-re-with-space 2885 (defconst org-link-re-with-space
2797 (concat 2886 (concat
2798 "<?\\(" (mapconcat 'identity org-link-types "\\|") "\\):" 2887 "<?\\(" (mapconcat 'identity org-link-types "\\|") "\\):"
2799 "\\([^" org-non-link-chars " ]" 2888 "\\([^" org-non-link-chars " ]"
2800 "[^" org-non-link-chars "]*" 2889 "[^" org-non-link-chars "]*"
2801 "[^" org-non-link-chars " ]\\)>?") 2890 "[^" org-non-link-chars " ]\\)>?")
2807 "\\([^" org-non-link-chars " ]" 2896 "\\([^" org-non-link-chars " ]"
2808 "[^]\t\n\r]*" 2897 "[^]\t\n\r]*"
2809 "[^" org-non-link-chars " ]\\)>?") 2898 "[^" org-non-link-chars " ]\\)>?")
2810 "Matches a link with spaces, optional angular brackets around it.") 2899 "Matches a link with spaces, optional angular brackets around it.")
2811 2900
2812 (defconst org-angle-link-re 2901 (defconst org-angle-link-re
2813 (concat 2902 (concat
2814 "<\\(" (mapconcat 'identity org-link-types "\\|") "\\):" 2903 "<\\(" (mapconcat 'identity org-link-types "\\|") "\\):"
2815 "\\([^" org-non-link-chars " ]" 2904 "\\([^" org-non-link-chars " ]"
2816 "[^" org-non-link-chars "]*" 2905 "[^" org-non-link-chars "]*"
2817 "\\)>") 2906 "\\)>")
2856 (defconst org-tr-regexp (concat org-ts-regexp "--?-?" org-ts-regexp) 2945 (defconst org-tr-regexp (concat org-ts-regexp "--?-?" org-ts-regexp)
2857 "Regular expression matching a time stamp range.") 2946 "Regular expression matching a time stamp range.")
2858 (defconst org-tsr-regexp (concat org-ts-regexp "\\(--?-?" 2947 (defconst org-tsr-regexp (concat org-ts-regexp "\\(--?-?"
2859 org-ts-regexp "\\)?") 2948 org-ts-regexp "\\)?")
2860 "Regular expression matching a time stamp or time stamp range.") 2949 "Regular expression matching a time stamp or time stamp range.")
2950
2951 (defvar org-§emph-face nil)
2952
2953 (defun org-do-emphasis-faces (limit)
2954 "Run through the buffer and add overlays to links."
2955 (if (re-search-forward org-emph-re limit t)
2956 (progn
2957 (font-lock-prepend-text-property (match-beginning 2) (match-end 2)
2958 'face
2959 (nth 1 (assoc (match-string 3)
2960 org-emphasis-alist)))
2961 (add-text-properties (match-beginning 2) (match-end 2)
2962 '(font-lock-multiline t))
2963 (backward-char 1)
2964 t)))
2861 2965
2862 (defun org-activate-plain-links (limit) 2966 (defun org-activate-plain-links (limit)
2863 "Run through the buffer and add overlays to links." 2967 "Run through the buffer and add overlays to links."
2864 (if (re-search-forward org-plain-link-re limit t) 2968 (if (re-search-forward org-plain-link-re limit t)
2865 (progn 2969 (progn
3048 (list (concat "\\[#[A-Z]\\]") '(0 'org-special-keyword t)) 3152 (list (concat "\\[#[A-Z]\\]") '(0 'org-special-keyword t))
3049 ;; Special keywords 3153 ;; Special keywords
3050 (list (concat "\\<" org-deadline-string) '(0 'org-special-keyword t)) 3154 (list (concat "\\<" org-deadline-string) '(0 'org-special-keyword t))
3051 (list (concat "\\<" org-scheduled-string) '(0 'org-special-keyword t)) 3155 (list (concat "\\<" org-scheduled-string) '(0 'org-special-keyword t))
3052 (list (concat "\\<" org-closed-string) '(0 'org-special-keyword t)) 3156 (list (concat "\\<" org-closed-string) '(0 'org-special-keyword t))
3157 (list (concat "\\<" org-clock-string) '(0 'org-special-keyword t))
3053 ;; Emphasis 3158 ;; Emphasis
3054 (if em (list org-bold-re 2 ''bold 'prepend)) 3159 (if em '(org-do-emphasis-faces))
3055 (if em (list org-italic-re 2 ''italic 'prepend))
3056 (if em (list org-underline-re 2 ''underline 'prepend))
3057 ;; Checkboxes, similar to Frank Ruell's org-checklet.el 3160 ;; Checkboxes, similar to Frank Ruell's org-checklet.el
3058 '("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[ X]\\]\\)" 3161 '("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[ X]\\]\\)"
3059 2 'bold prepend) 3162 2 'bold prepend)
3060 ;; COMMENT 3163 ;; COMMENT
3061 (list (concat "^\\*+[ \t]*\\<\\(" org-comment-string 3164 (list (concat "^\\*+[ \t]*\\<\\(" org-comment-string
3146 3249
3147 (let* ((outline-regexp 3250 (let* ((outline-regexp
3148 (if org-cycle-include-plain-lists 3251 (if org-cycle-include-plain-lists
3149 "\\*+\\|\\([ \t]*\\)\\([-+*]\\|[0-9]+[.)]\\) " 3252 "\\*+\\|\\([ \t]*\\)\\([-+*]\\|[0-9]+[.)]\\) "
3150 outline-regexp)) 3253 outline-regexp))
3151 (bob-special (and org-cycle-global-at-bob (bobp) 3254 (bob-special (and org-cycle-global-at-bob (bobp)
3152 (not (looking-at outline-regexp)))) 3255 (not (looking-at outline-regexp))))
3153 (org-cycle-hook (if bob-special nil org-cycle-hook)) 3256 (org-cycle-hook (if bob-special nil org-cycle-hook))
3154 (pos (point))) 3257 (pos (point)))
3155 3258
3156 (if (or bob-special (equal arg '(4))) 3259 (if (or bob-special (equal arg '(4)))
3266 (t (save-excursion 3369 (t (save-excursion
3267 (org-back-to-heading) 3370 (org-back-to-heading)
3268 (org-cycle)))))) 3371 (org-cycle))))))
3269 3372
3270 ;;;###autoload 3373 ;;;###autoload
3271 (defun org-global-cycle () 3374 (defun org-global-cycle (&optional arg)
3272 "Cycle the global visibility. For details see `org-cycle'." 3375 "Cycle the global visibility. For details see `org-cycle'."
3273 (interactive) 3376 (interactive "P")
3274 (org-cycle '(4))) 3377 (if (integerp arg)
3378 (progn
3379 (show-all)
3380 (hide-sublevels arg)
3381 (setq org-cycle-global-status 'contents))
3382 (org-cycle '(4))))
3275 3383
3276 (defun org-overview () 3384 (defun org-overview ()
3277 "Switch to overview mode, shoing only top-level headlines. 3385 "Switch to overview mode, shoing only top-level headlines.
3278 Really, this shows all headlines with level equal or greater than the level 3386 Really, this shows all headlines with level equal or greater than the level
3279 of the first headline in the buffer. This is important, because if the 3387 of the first headline in the buffer. This is important, because if the
3482 (progn 3590 (progn
3483 (org-back-to-heading) 3591 (org-back-to-heading)
3484 (match-string 0)) 3592 (match-string 0))
3485 (error "*")))) 3593 (error "*"))))
3486 pos) 3594 pos)
3487 (cond 3595 (cond
3488 ((and (org-on-heading-p) (bolp) 3596 ((and (org-on-heading-p) (bolp)
3489 (save-excursion (backward-char 1) (not (org-invisible-p)))) 3597 (save-excursion (backward-char 1) (not (org-invisible-p))))
3490 (open-line 1)) 3598 (open-line 1))
3491 ((bolp) nil) 3599 ((and (bolp) (save-excursion
3600 (backward-char 1) (not (org-invisible-p))))
3601 nil)
3492 (t (newline))) 3602 (t (newline)))
3493 (insert head) (just-one-space) 3603 (insert head) (just-one-space)
3494 (setq pos (point)) 3604 (setq pos (point))
3495 (end-of-line 1) 3605 (end-of-line 1)
3496 (unless (= (point) pos) (just-one-space) (backward-delete-char 1)) 3606 (unless (= (point) pos) (just-one-space) (backward-delete-char 1))
3655 (outline-next-heading) 3765 (outline-next-heading)
3656 (< (point) end)) 3766 (< (point) end))
3657 (not (eobp))) 3767 (not (eobp)))
3658 (funcall fun))))) 3768 (funcall fun)))))
3659 3769
3770 ;; FIXME: this does not work well with Tabulators. This has to be re-written entirely.
3660 (defun org-fixup-indentation (from to prohibit) 3771 (defun org-fixup-indentation (from to prohibit)
3661 "Change the indentation in the current entry by re-replacing FROM with TO. 3772 "Change the indentation in the current entry by re-replacing FROM with TO.
3662 However, if the regexp PROHIBIT matches at all, don't do anything. 3773 However, if the regexp PROHIBIT matches at all, don't do anything.
3663 This is being used to change indentation along with the length of the 3774 This is being used to change indentation along with the length of the
3664 heading marker. But if there are any lines which are not indented, nothing 3775 heading marker. But if there are any lines which are not indented, nothing
3997 (org-end-of-item) 4108 (org-end-of-item)
3998 (setq end (point)) 4109 (setq end (point))
3999 (setq ind1 (org-get-indentation)) 4110 (setq ind1 (org-get-indentation))
4000 (unless (and (org-at-item-p) (= ind ind1)) 4111 (unless (and (org-at-item-p) (= ind ind1))
4001 (goto-char pos) 4112 (goto-char pos)
4002 (error "On last item")))) 4113 (error "On last item"))))
4003 4114
4004 (defun org-previous-item () 4115 (defun org-previous-item ()
4005 "Move to the beginning of the previous item in the current plain list. 4116 "Move to the beginning of the previous item in the current plain list.
4006 Error if not at a plain list, or if this is the last item in the list." 4117 Error if not at a plain list, or if this is the last item in the list."
4007 (interactive) 4118 (interactive)
4558 (goto-char (match-end 1)) 4669 (goto-char (match-end 1))
4559 (setq col (current-column)) 4670 (setq col (current-column))
4560 (goto-char (1+ (match-end 0))) 4671 (goto-char (1+ (match-end 0)))
4561 (if (and (not (looking-at outline-regexp)) 4672 (if (and (not (looking-at outline-regexp))
4562 (looking-at (concat "[^\r\n]*?" org-keyword-time-regexp 4673 (looking-at (concat "[^\r\n]*?" org-keyword-time-regexp
4563 "[^\r\n]*"))) 4674 "[^\r\n]*"))
4675 (not (equal (match-string 1) org-clock-string)))
4564 (narrow-to-region (match-beginning 0) (match-end 0)) 4676 (narrow-to-region (match-beginning 0) (match-end 0))
4565 (insert "\n") 4677 (insert "\n")
4566 (backward-char 1) 4678 (backward-char 1)
4567 (narrow-to-region (point) (point)) 4679 (narrow-to-region (point) (point))
4568 (indent-to-column col)) 4680 (indent-to-column col))
4587 ((eq what 'deadline) org-deadline-string) 4699 ((eq what 'deadline) org-deadline-string)
4588 ((eq what 'closed) org-closed-string)) 4700 ((eq what 'closed) org-closed-string))
4589 " ") 4701 " ")
4590 (insert 4702 (insert
4591 (setq ts 4703 (setq ts
4592 (format-time-string 4704 (format-time-string
4593 (if (eq what 'closed) 4705 (if (eq what 'closed)
4594 (concat "[" (substring (cdr org-time-stamp-formats) 1 -1) "]") 4706 (concat "[" (substring (cdr org-time-stamp-formats) 1 -1) "]")
4595 (car org-time-stamp-formats)) 4707 (car org-time-stamp-formats))
4596 time)))) 4708 time))))
4597 (goto-char (point-min)) 4709 (goto-char (point-min))
5256 "Insert time stamp corresponding to cursor date in *Calendar* buffer. 5368 "Insert time stamp corresponding to cursor date in *Calendar* buffer.
5257 If there is already a time stamp at the cursor position, update it." 5369 If there is already a time stamp at the cursor position, update it."
5258 (interactive) 5370 (interactive)
5259 (org-timestamp-change 0 'calendar)) 5371 (org-timestamp-change 0 'calendar))
5260 5372
5373 ;;; The clock for measuring work time.
5374
5375 (defvar org-clock-marker (make-marker)
5376 "Marker recording the last clock-in.")
5377
5378 (defun org-clock-in ()
5379 "Start the clock on the current item.
5380 If necessary, clock-out of the currently active clock."
5381 (interactive)
5382 (org-clock-out t)
5383 (let (ts)
5384 (save-excursion
5385 (org-back-to-heading t)
5386 (beginning-of-line 2)
5387 (if (and (looking-at (concat "[ \t]*" org-keyword-time-regexp))
5388 (not (equal (match-string 1) org-clock-string)))
5389 (beginning-of-line 1))
5390 (insert "\n") (backward-char 1)
5391 (indent-relative)
5392 (insert org-clock-string " "
5393 (setq ts (concat "[" (format-time-string
5394 (substring
5395 (cdr org-time-stamp-formats) 1 -1)
5396 (current-time))
5397 "]")))
5398 (move-marker org-clock-marker (point))
5399 (message "Clock started at %s" ts))))
5400
5401 (defun org-clock-out (&optional fail-quietly)
5402 "Stop the currently running clock.
5403 If there is no running clock, throw an error, unless FAIL-QUIETLY is set."
5404 (interactive)
5405 (catch 'exit
5406 (if (not (marker-buffer org-clock-marker))
5407 (if fail-quietly (throw 'exit t) (error "No active clock")))
5408 (let (ts te s h m)
5409 (save-excursion
5410 (set-buffer (marker-buffer org-clock-marker))
5411 (goto-char org-clock-marker)
5412 (beginning-of-line 1)
5413 (if (and (looking-at (concat "[ \t]*" org-keyword-time-regexp))
5414 (equal (match-string 1) org-clock-string))
5415 (setq ts (match-string 2))
5416 (if fail-quietly (throw 'exit nil) (error "Clock start time is gone")))
5417 (goto-char org-clock-marker)
5418 (setq te (concat "[" (format-time-string
5419 (substring
5420 (cdr org-time-stamp-formats) 1 -1)
5421 (current-time))
5422 "]"))
5423 (setq s (- (time-to-seconds (apply 'encode-time (org-parse-time-string te)))
5424 (time-to-seconds (apply 'encode-time (org-parse-time-string ts))))
5425 h (floor (/ s 3600))
5426 s (- s (* 3600 h))
5427 m (floor (/ s 60))
5428 s (- s (* 60 s)))
5429 (insert "--" te " => " (format "%2d:%02d" h m))
5430 (move-marker org-clock-marker nil)
5431 (message "Clock stopped at %s after HH:MM = %d:%02d" te h m)))))
5432
5433 (defun org-clock-cancel ()
5434 "Cancel the running clock be removing the start timestamp."
5435 (interactive)
5436 (if (not (marker-buffer org-clock-marker))
5437 (error "No active clock"))
5438 (save-excursion
5439 (set-buffer (marker-buffer org-clock-marker))
5440 (goto-char org-clock-marker)
5441 (delete-region (1- (point-at-bol)) (point-at-eol)))
5442 (message "Clock canceled"))
5443
5444 (defvar org-clock-file-total-minutes nil
5445 "Holds the file total time in minutes, after a call to `org-clock-sum'.")
5446 (make-variable-buffer-local 'org-clock-file-total-minutes)
5447
5448 (defun org-clock-sum ()
5449 "Sum the times for each subtree.
5450 Puts the resulting times in minutes as a text property on each headline."
5451 (interactive)
5452 (remove-text-properties (point-min) (point-max) '(:org-clock-minutes t))
5453 (let* ((re (concat "^\\(\\*+\\)[ \t]\\|^[ \t]*"
5454 org-clock-string
5455 ".*=>[ \t]*\\([0-9]+\\):\\([0-9]+\\)[ \t]*$"))
5456 (lmax 30)
5457 (ltimes (make-vector lmax 0))
5458 (t1 0)
5459 (level 0)
5460 (lastlevel 0) time)
5461 (save-excursion
5462 (goto-char (point-max))
5463 (while (re-search-backward re nil t)
5464 (if (match-end 2)
5465 ;; A time
5466 (setq t1 (+ t1 (* 60 (string-to-number (match-string 2)))
5467 (string-to-number (match-string 3))))
5468 ;; A headline
5469 (setq level (- (match-end 1) (match-beginning 1)))
5470 (when (or (> t1 0) (> (aref ltimes level) 0))
5471 (loop for l from 0 to level do
5472 (aset ltimes l (+ (aref ltimes l) t1)))
5473 (setq t1 0 time (aref ltimes level))
5474 (loop for l from level to (1- lmax) do
5475 (aset ltimes l 0))
5476 (goto-char (match-beginning 0))
5477 (put-text-property (point) (point-at-eol) :org-clock-minutes time))))
5478 (setq org-clock-file-total-minutes (aref ltimes 0)))))
5479
5480 (defun org-clock-display (&optional total-only)
5481 "Show subtree times in the entire buffer.
5482 If TOTAL-ONLY is non-nil, only show the total time for the entire file
5483 in the echo area."
5484 (interactive)
5485 (org-remove-clock-overlays)
5486 (let (time h m p)
5487 (org-clock-sum)
5488 (unless total-only
5489 (save-excursion
5490 (goto-char (point-min))
5491 (while (setq p (next-single-property-change (point) :org-clock-minutes))
5492 (goto-char p)
5493 (when (setq time (get-text-property p :org-clock-minutes))
5494 (org-put-clock-overlay time (funcall outline-level))))
5495 (setq h (/ org-clock-file-total-minutes 60)
5496 m (- org-clock-file-total-minutes (* 60 h)))
5497 ;; Arrange to remove the overlays upon next change.
5498 (org-add-hook 'before-change-functions 'org-remove-clock-overlays
5499 nil 'local)))
5500 (message "Total file time: %d:%02d (%d hours and %d minutes)" h m h m)))
5501
5502 (defvar org-clock-overlays nil)
5503 (defun org-put-clock-overlay (time &optional level)
5504 "Put an overlays on the current line, displaying TIME.
5505 If LEVEL is given, prefix time with a corresponding number of stars.
5506 This creates a new overlay and stores it in `org-clock-overlays', so that it
5507 will be easy to remove."
5508 (let* ((c 60) (h (floor (/ time 60))) (m (- time (* 60 h)))
5509 (l (if level (org-get-legal-level level 0) 0))
5510 (off 0)
5511 ov tx)
5512 (move-to-column c)
5513 (if (eolp) (setq off 1))
5514 (unless (eolp) (skip-chars-backward "^ \t"))
5515 (skip-chars-backward " \t")
5516 (setq ov (org-make-overlay (- (point) off) (point-at-eol))
5517 tx (concat (make-string (+ off (max 0 (- c (current-column)))) ?.)
5518 (org-add-props (format "%s %2d:%02d%s"
5519 (make-string l ?*) h m
5520 (make-string (- 10 l) ?\ ))
5521 '(face secondary-selection))
5522 ""))
5523 (org-overlay-put ov 'display tx)
5524 (push ov org-clock-overlays)))
5525
5526 (defun org-remove-clock-overlays (&optional beg end noremove)
5527 "Remove the occur highlights from the buffer.
5528 BEG and END are ignored. If NOREMOVE is nil, remove this function
5529 from the `before-change-functions' in the current buffer."
5530 (interactive)
5531 (mapc 'org-delete-overlay org-clock-overlays)
5532 (setq org-clock-overlays nil)
5533 (unless noremove
5534 (remove-hook 'before-change-functions
5535 'org-remove-clock-overlays 'local)))
5536
5537 (defun org-clock-out-if-current ()
5538 "Clock out if the current entry contains the running clock.
5539 This is used to stop the clock after a TODO entry is marked DONE."
5540 (when (and (equal state org-done-string)
5541 (equal (marker-buffer org-clock-marker) (current-buffer))
5542 (< (point) org-clock-marker)
5543 (> (save-excursion (outline-next-heading) (point))
5544 org-clock-marker))
5545 (org-clock-out)))
5546
5547 (add-hook 'org-after-todo-state-change-hook
5548 'org-clock-out-if-current)
5549
5550 (defun org-check-running-clock ()
5551 "Check if the current buffer contains the running clock.
5552 If yes, offer to stop it and to save the buffer with the changes."
5553 (when (and (equal (marker-buffer org-clock-marker) (current-buffer))
5554 (y-or-n-p (format "Clock-out in buffer %s before killing it? "
5555 (buffer-name))))
5556 (org-clock-out)
5557 (when (y-or-n-p "Save changed buffer?")
5558 (save-buffer))))
5559
5261 ;;; Agenda, and Diary Integration 5560 ;;; Agenda, and Diary Integration
5262 5561
5263 ;;; Define the mode 5562 ;;; Define the mode
5264 5563
5265 (defvar org-agenda-mode-map (make-sparse-keymap) 5564 (defvar org-agenda-mode-map (make-sparse-keymap)
5359 (define-key org-agenda-mode-map "s" 'org-agenda-sunrise-sunset) 5658 (define-key org-agenda-mode-map "s" 'org-agenda-sunrise-sunset)
5360 (define-key org-agenda-mode-map "S" 'org-agenda-sunrise-sunset) 5659 (define-key org-agenda-mode-map "S" 'org-agenda-sunrise-sunset)
5361 (define-key org-agenda-mode-map "h" 'org-agenda-holidays) 5660 (define-key org-agenda-mode-map "h" 'org-agenda-holidays)
5362 (define-key org-agenda-mode-map "H" 'org-agenda-holidays) 5661 (define-key org-agenda-mode-map "H" 'org-agenda-holidays)
5363 (define-key org-agenda-mode-map "+" 'org-agenda-priority-up) 5662 (define-key org-agenda-mode-map "+" 'org-agenda-priority-up)
5663 (define-key org-agenda-mode-map "I" 'org-agenda-clock-in)
5664 (define-key org-agenda-mode-map "O" 'org-clock-out)
5665 (define-key org-agenda-mode-map "X" 'org-clock-cancel)
5364 (define-key org-agenda-mode-map "-" 'org-agenda-priority-down) 5666 (define-key org-agenda-mode-map "-" 'org-agenda-priority-down)
5365 (define-key org-agenda-mode-map (org-key 'S-up) 'org-agenda-priority-up) 5667 (define-key org-agenda-mode-map (org-key 'S-up) 'org-agenda-priority-up)
5366 (define-key org-agenda-mode-map (org-key 'S-down) 'org-agenda-priority-down) 5668 (define-key org-agenda-mode-map (org-key 'S-down) 'org-agenda-priority-down)
5367 (define-key org-agenda-mode-map [?\C-c ?\C-x (up)] 'org-agenda-priority-up) 5669 (define-key org-agenda-mode-map [?\C-c ?\C-x (up)] 'org-agenda-priority-up)
5368 (define-key org-agenda-mode-map [?\C-c ?\C-x (down)] 'org-agenda-priority-down) 5670 (define-key org-agenda-mode-map [?\C-c ?\C-x (down)] 'org-agenda-priority-down)
6617 'keymap org-agenda-keymap 6919 'keymap org-agenda-keymap
6618 'help-echo 6920 'help-echo
6619 (format "mouse-2 or RET jump to org file %s" 6921 (format "mouse-2 or RET jump to org file %s"
6620 (abbreviate-file-name buffer-file-name)))) 6922 (abbreviate-file-name buffer-file-name))))
6621 (regexp (concat 6923 (regexp (concat
6622 "\\<" org-closed-string " *\\[" 6924 "\\<\\(" org-closed-string "\\|" org-clock-string "\\) *\\["
6623 (regexp-quote 6925 (regexp-quote
6624 (substring 6926 (substring
6625 (format-time-string 6927 (format-time-string
6626 (car org-time-stamp-formats) 6928 (car org-time-stamp-formats)
6627 (apply 'encode-time ; DATE bound by calendar 6929 (apply 'encode-time ; DATE bound by calendar
6628 (list 0 0 0 (nth 1 date) (car date) (nth 2 date)))) 6930 (list 0 0 0 (nth 1 date) (car date) (nth 2 date))))
6629 1 11)))) 6931 1 11))))
6630 marker hdmarker priority category tags 6932 marker hdmarker priority category tags closedp
6631 ee txt timestr) 6933 ee txt timestr)
6632 (goto-char (point-min)) 6934 (goto-char (point-min))
6633 (while (re-search-forward regexp nil t) 6935 (while (re-search-forward regexp nil t)
6634 (if (not (save-match-data (org-at-date-range-p))) 6936 (if (not (save-match-data (org-at-date-range-p)))
6635 (progn 6937 (progn
6636 (setq marker (org-agenda-new-marker (match-beginning 0)) 6938 (setq marker (org-agenda-new-marker (match-beginning 0))
6939 closedp (equal (match-string 1) org-closed-string)
6637 category (org-get-category (match-beginning 0)) 6940 category (org-get-category (match-beginning 0))
6638 timestr (buffer-substring (match-beginning 0) (point-at-eol)) 6941 timestr (buffer-substring (match-beginning 0) (point-at-eol))
6639 ;; donep (org-entry-is-done-p) 6942 ;; donep (org-entry-is-done-p)
6640 ) 6943 )
6641 (if (string-match "\\]" timestr) 6944 (if (string-match "\\]" timestr)
6647 (goto-char (match-end 1)) 6950 (goto-char (match-end 1))
6648 (setq hdmarker (org-agenda-new-marker) 6951 (setq hdmarker (org-agenda-new-marker)
6649 tags (org-get-tags-at)) 6952 tags (org-get-tags-at))
6650 (looking-at "\\*+[ \t]*\\([^\r\n]+\\)") 6953 (looking-at "\\*+[ \t]*\\([^\r\n]+\\)")
6651 (setq txt (org-format-agenda-item 6954 (setq txt (org-format-agenda-item
6652 "Closed: " 6955 (if closedp "Closed: " "Clocked: ")
6653 (match-string 1) category tags timestr))) 6956 (match-string 1) category tags timestr)))
6654 (setq txt org-agenda-no-heading-message)) 6957 (setq txt org-agenda-no-heading-message))
6655 (setq priority 100000) 6958 (setq priority 100000)
6656 (org-add-props txt props 6959 (org-add-props txt props
6657 'org-marker marker 'org-hd-marker hdmarker 'face 'org-done 6960 'org-marker marker 'org-hd-marker hdmarker 'face 'org-done
6699 (if (string-match org-looking-at-done-regexp head) 7002 (if (string-match org-looking-at-done-regexp head)
6700 (setq txt nil) 7003 (setq txt nil)
6701 (setq txt (org-format-agenda-item 7004 (setq txt (org-format-agenda-item
6702 (format "In %3d d.: " diff) head category tags)))) 7005 (format "In %3d d.: " diff) head category tags))))
6703 (setq txt org-agenda-no-heading-message)) 7006 (setq txt org-agenda-no-heading-message))
6704 (when txt 7007 (when txt
6705 (setq face (cond ((<= diff 0) 'org-warning) 7008 (setq face (cond ((<= diff 0) 'org-warning)
6706 ((<= diff 5) 'org-upcoming-deadline) 7009 ((<= diff 5) 'org-upcoming-deadline)
6707 (t nil))) 7010 (t nil)))
6708 (org-add-props txt props 7011 (org-add-props txt props
6709 'org-marker (org-agenda-new-marker pos) 7012 'org-marker (org-agenda-new-marker pos)
6895 ;; Tags are in the string 7198 ;; Tags are in the string
6896 (if (or (eq org-agenda-remove-tags-when-in-prefix t) 7199 (if (or (eq org-agenda-remove-tags-when-in-prefix t)
6897 (and org-agenda-remove-tags-when-in-prefix 7200 (and org-agenda-remove-tags-when-in-prefix
6898 org-prefix-has-tag)) 7201 org-prefix-has-tag))
6899 (setq txt (replace-match "" t t txt)) 7202 (setq txt (replace-match "" t t txt))
6900 (setq txt (replace-match 7203 (setq txt (replace-match
6901 (concat (make-string (max (- 50 (length txt)) 1) ?\ ) 7204 (concat (make-string (max (- 50 (length txt)) 1) ?\ )
6902 (match-string 2 txt)) 7205 (match-string 2 txt))
6903 t t txt)))) 7206 t t txt))))
6904 7207
6905 ;; Create the final string 7208 ;; Create the final string
7081 (defun org-agenda-show-tags () 7384 (defun org-agenda-show-tags ()
7082 "Show the tags applicable to the current item." 7385 "Show the tags applicable to the current item."
7083 (interactive) 7386 (interactive)
7084 (let* ((tags (get-text-property (point-at-bol) 'tags))) 7387 (let* ((tags (get-text-property (point-at-bol) 'tags)))
7085 (if tags 7388 (if tags
7086 (message "Tags are :%s:" 7389 (message "Tags are :%s:"
7087 (org-no-properties (mapconcat 'identity tags ":"))) 7390 (org-no-properties (mapconcat 'identity tags ":")))
7088 (message "No tags associated with this line")))) 7391 (message "No tags associated with this line"))))
7089 7392
7090 (defun org-agenda-goto (&optional highlight) 7393 (defun org-agenda-goto (&optional highlight)
7091 "Go to the Org-mode file which contains the item at point." 7394 "Go to the Org-mode file which contains the item at point."
7281 (save-match-data 7584 (save-match-data
7282 (org-back-to-heading t) 7585 (org-back-to-heading t)
7283 (condition-case nil 7586 (condition-case nil
7284 (while t 7587 (while t
7285 (if (looking-at "[^\r\n]+?:\\([a-zA-Z_@0-9:]+\\):[ \t]*\\([\n\r]\\|\\'\\)") 7588 (if (looking-at "[^\r\n]+?:\\([a-zA-Z_@0-9:]+\\):[ \t]*\\([\n\r]\\|\\'\\)")
7286 (setq tags (append (org-split-string 7589 (setq tags (append (org-split-string
7287 (org-match-string-no-properties 1) ":") 7590 (org-match-string-no-properties 1) ":")
7288 tags))) 7591 tags)))
7289 (or org-use-tag-inheritance (error "")) 7592 (or org-use-tag-inheritance (error ""))
7290 (org-up-heading-all 1)) 7593 (org-up-heading-all 1))
7291 (error nil)))) 7594 (error nil))))
7397 (and (memq (char-before) '(?\n ?\r)) (skip-chars-forward "^\n\r")) 7700 (and (memq (char-before) '(?\n ?\r)) (skip-chars-forward "^\n\r"))
7398 (if (and (re-search-backward "[\r\n]\\*" nil t) 7701 (if (and (re-search-backward "[\r\n]\\*" nil t)
7399 (looking-at "[\r\n]\\*+[ \t]+\\([^\r\n]*\\)")) 7702 (looking-at "[\r\n]\\*+[ \t]+\\([^\r\n]*\\)"))
7400 (match-string 1) 7703 (match-string 1)
7401 ""))) 7704 "")))
7705
7706 (defun org-agenda-clock-in (&optional arg)
7707 "Start the clock on the currently selected item."
7708 (interactive "P")
7709 (org-agenda-check-no-diary)
7710 (let* ((marker (or (get-text-property (point) 'org-marker)
7711 (org-agenda-error)))
7712 (buffer (marker-buffer marker))
7713 (pos (marker-position marker))
7714 (hdmarker (get-text-property (point) 'org-hd-marker)))
7715 (with-current-buffer (marker-buffer marker)
7716 (widen)
7717 (goto-char pos)
7718 (org-clock-in))))
7402 7719
7403 (defun org-agenda-diary-entry () 7720 (defun org-agenda-diary-entry ()
7404 "Make a diary entry, like the `i' command from the calendar. 7721 "Make a diary entry, like the `i' command from the calendar.
7405 All the standard commands work: block, weekly etc." 7722 All the standard commands work: block, weekly etc."
7406 (interactive) 7723 (interactive)
7835 (org-fast-tag-insert "Inherited" inherited i-face "\n") 8152 (org-fast-tag-insert "Inherited" inherited i-face "\n")
7836 (org-fast-tag-insert "Current" current c-face "\n\n") 8153 (org-fast-tag-insert "Current" current c-face "\n\n")
7837 (setq tbl table char ?a cnt 0) 8154 (setq tbl table char ?a cnt 0)
7838 (while (setq e (pop tbl)) 8155 (while (setq e (pop tbl))
7839 (cond 8156 (cond
7840 ((equal e '(:startgroup)) 8157 ((equal e '(:startgroup))
7841 (push '() groups) (setq ingroup t) 8158 (push '() groups) (setq ingroup t)
7842 (when (not (= cnt 0)) 8159 (when (not (= cnt 0))
7843 (setq cnt 0) 8160 (setq cnt 0)
7844 (insert "\n")) 8161 (insert "\n"))
7845 (insert "{ ")) 8162 (insert "{ "))
7850 (setq tg (car e) c2 nil) 8167 (setq tg (car e) c2 nil)
7851 (if (cdr e) 8168 (if (cdr e)
7852 (setq c (cdr e)) 8169 (setq c (cdr e))
7853 ;; automatically assign a character. 8170 ;; automatically assign a character.
7854 (setq c1 (string-to-char 8171 (setq c1 (string-to-char
7855 (downcase (substring 8172 (downcase (substring
7856 tg (if (= (string-to-char tg) ?@) 1 0))))) 8173 tg (if (= (string-to-char tg) ?@) 1 0)))))
7857 (if (or (rassoc c1 ntable) (rassoc c1 table)) 8174 (if (or (rassoc c1 ntable) (rassoc c1 table))
7858 (while (or (rassoc char ntable) (rassoc char table)) 8175 (while (or (rassoc char ntable) (rassoc char table))
7859 (setq char (1+ char))) 8176 (setq char (1+ char)))
7860 (setq c2 c1)) 8177 (setq c2 c1))
7883 (message "[key]:Toggle SPC: clear current RET accept%s" 8200 (message "[key]:Toggle SPC: clear current RET accept%s"
7884 (if groups " [!] ignore goups" "")) 8201 (if groups " [!] ignore goups" ""))
7885 (setq c (read-char-exclusive)) 8202 (setq c (read-char-exclusive))
7886 (cond 8203 (cond
7887 ((= c ?\r) (throw 'exit t)) 8204 ((= c ?\r) (throw 'exit t))
7888 ((= c ?!) 8205 ((= c ?!)
7889 (setq groups nil) 8206 (setq groups nil)
7890 (goto-char (point-min)) 8207 (goto-char (point-min))
7891 (while (re-search-forward "[{}]" nil t) (replace-match " "))) 8208 (while (re-search-forward "[{}]" nil t) (replace-match " ")))
7892 ((or (= c ?\C-g) 8209 ((or (= c ?\C-g)
7893 (and (= c ?q) (not (rassoc c ntable)))) 8210 (and (= c ?q) (not (rassoc c ntable))))
8196 (s0 (mapconcat 'identity (org-split-string s "[ \t\r\n]+") " ")) 8513 (s0 (mapconcat 'identity (org-split-string s "[ \t\r\n]+") " "))
8197 (pos (point)) 8514 (pos (point))
8198 (pre "") (post "") 8515 (pre "") (post "")
8199 words re0 re1 re2 re3 re4 re5 re2a reall camel) 8516 words re0 re1 re2 re3 re4 re5 re2a reall camel)
8200 (cond 8517 (cond
8201 ;; First check if there are any special 8518 ;; First check if there are any special
8202 ((run-hook-with-args-until-success 'org-execute-file-search-functions s)) 8519 ((run-hook-with-args-until-success 'org-execute-file-search-functions s))
8203 ;; Now try the builtin stuff 8520 ;; Now try the builtin stuff
8204 ((save-excursion 8521 ((save-excursion
8205 (goto-char (point-min)) 8522 (goto-char (point-min))
8206 (and 8523 (and
8642 With arg query-description, ask at each match for a description text to use 8959 With arg query-description, ask at each match for a description text to use
8643 for this link." 8960 for this link."
8644 (interactive (list (y-or-n-p "Would you like to be queried for a description at each link?"))) 8961 (interactive (list (y-or-n-p "Would you like to be queried for a description at each link?")))
8645 (save-excursion 8962 (save-excursion
8646 (goto-char (point-min)) 8963 (goto-char (point-min))
8647 (let ((re (concat "\\([^[]\\)<\\(" 8964 (let ((re (concat "\\([^[]\\)<\\("
8648 "\\(" (mapconcat 'identity org-link-types "\\|") 8965 "\\(" (mapconcat 'identity org-link-types "\\|")
8649 "\\):" 8966 "\\):"
8650 "[^" org-non-link-chars "]+\\)>")) 8967 "[^" org-non-link-chars "]+\\)>"))
8651 l1 l2 (cnt 0)) 8968 l1 l2 (cnt 0))
8652 (while (re-search-forward re nil t) 8969 (while (re-search-forward re nil t)
8653 (setq cnt (1+ cnt) 8970 (setq cnt (1+ cnt)
8761 (or (bbdb-record-name (bbdb-current-record)) 9078 (or (bbdb-record-name (bbdb-current-record))
8762 (bbdb-record-company (bbdb-current-record)))) 9079 (bbdb-record-company (bbdb-current-record))))
8763 link (org-make-link cpltxt))) 9080 link (org-make-link cpltxt)))
8764 9081
8765 ((eq major-mode 'Info-mode) 9082 ((eq major-mode 'Info-mode)
8766 (setq link (org-make-link "info:" 9083 (setq link (org-make-link "info:"
8767 (file-name-nondirectory Info-current-file) 9084 (file-name-nondirectory Info-current-file)
8768 ":" Info-current-node)) 9085 ":" Info-current-node))
8769 (setq cpltxt (concat (file-name-nondirectory Info-current-file) 9086 (setq cpltxt (concat (file-name-nondirectory Info-current-file)
8770 ":" Info-current-node))) 9087 ":" Info-current-node)))
8771 9088
9108 (<= (match-beginning 0) pos) 9425 (<= (match-beginning 0) pos)
9109 (>= (match-end 0) pos))) 9426 (>= (match-end 0) pos)))
9110 ;; We do have a link at point, and we are going to edit it. 9427 ;; We do have a link at point, and we are going to edit it.
9111 (setq remove (list (match-beginning 0) (match-end 0))) 9428 (setq remove (list (match-beginning 0) (match-end 0)))
9112 (setq desc (if (match-end 3) (org-match-string-no-properties 3))) 9429 (setq desc (if (match-end 3) (org-match-string-no-properties 3)))
9113 (setq link (read-string "Link: " 9430 (setq link (read-string "Link: "
9114 (org-link-unescape 9431 (org-link-unescape
9115 (org-match-string-no-properties 1))))) 9432 (org-match-string-no-properties 1)))))
9116 (complete-file 9433 (complete-file
9117 ;; Completing read for file names. 9434 ;; Completing read for file names.
9118 (setq file (read-file-name "File: ")) 9435 (setq file (read-file-name "File: "))
9119 (let ((pwd (file-name-as-directory (expand-file-name "."))) 9436 (let ((pwd (file-name-as-directory (expand-file-name ".")))
9170 (setq path (expand-file-name path))) 9487 (setq path (expand-file-name path)))
9171 ((eq org-link-file-path-type 'relative) 9488 ((eq org-link-file-path-type 'relative)
9172 (setq path (file-relative-name path))) 9489 (setq path (file-relative-name path)))
9173 (t 9490 (t
9174 (save-match-data 9491 (save-match-data
9175 (if (string-match (concat "^" (regexp-quote 9492 (if (string-match (concat "^" (regexp-quote
9176 (file-name-as-directory 9493 (file-name-as-directory
9177 (expand-file-name ".")))) 9494 (expand-file-name "."))))
9178 (expand-file-name path)) 9495 (expand-file-name path))
9179 ;; We are linking a file with relative path name. 9496 ;; We are linking a file with relative path name.
9180 (setq path (substring (expand-file-name path) 9497 (setq path (substring (expand-file-name path)
9185 (unless (string-match "\\S-" desc) (setq desc nil)) 9502 (unless (string-match "\\S-" desc) (setq desc nil))
9186 (if remove (apply 'delete-region remove)) 9503 (if remove (apply 'delete-region remove))
9187 (insert (org-make-link-string link desc)))) 9504 (insert (org-make-link-string link desc))))
9188 9505
9189 (defun org-completing-read (&rest args) 9506 (defun org-completing-read (&rest args)
9190 (let ((minibuffer-local-completion-map 9507 (let ((minibuffer-local-completion-map
9191 (copy-keymap minibuffer-local-completion-map))) 9508 (copy-keymap minibuffer-local-completion-map)))
9192 (define-key minibuffer-local-completion-map " " 'self-insert-command) 9509 (define-key minibuffer-local-completion-map " " 'self-insert-command)
9193 (apply 'completing-read args))) 9510 (apply 'completing-read args)))
9194 9511
9195 ;;; Hooks for remember.el 9512 ;;; Hooks for remember.el
9665 (setq f1 (min fmax (or (string-match org-bracket-link-regexp xx) fmax))) 9982 (setq f1 (min fmax (or (string-match org-bracket-link-regexp xx) fmax)))
9666 (unless (> f1 1) 9983 (unless (> f1 1)
9667 (error "Cannot narrow field starting with wide link \"%s\"" 9984 (error "Cannot narrow field starting with wide link \"%s\""
9668 (match-string 0 xx))) 9985 (match-string 0 xx)))
9669 (add-text-properties f1 (length xx) (list 'org-cwidth t) xx) 9986 (add-text-properties f1 (length xx) (list 'org-cwidth t) xx)
9670 (add-text-properties (- f1 2) f1 9987 (add-text-properties (- f1 2) f1
9671 (list 'display org-narrow-column-arrow) 9988 (list 'display org-narrow-column-arrow)
9672 xx))))) 9989 xx)))))
9673 ;; Get the maximum width for each column 9990 ;; Get the maximum width for each column
9674 (push (apply 'max 1 (mapcar 'org-string-width column)) lengths) 9991 (push (apply 'max 1 (mapcar 'org-string-width column)) lengths)
9675 ;; Get the fraction of numbers, to decide about alignment of the column 9992 ;; Get the fraction of numbers, to decide about alignment of the column
10227 (error "Not at a table")) 10544 (error "Not at a table"))
10228 (let ((line (org-table-clean-line 10545 (let ((line (org-table-clean-line
10229 (buffer-substring (point-at-bol) (point-at-eol)))) 10546 (buffer-substring (point-at-bol) (point-at-eol))))
10230 (col (current-column))) 10547 (col (current-column)))
10231 (while (string-match "|\\( +\\)|" line) 10548 (while (string-match "|\\( +\\)|" line)
10232 (setq line (replace-match 10549 (setq line (replace-match
10233 (concat "+" (make-string (- (match-end 1) (match-beginning 1)) 10550 (concat "+" (make-string (- (match-end 1) (match-beginning 1))
10234 ?-) "|") t t line))) 10551 ?-) "|") t t line)))
10235 (and (string-match "\\+" line) (setq line (replace-match "|" t t line))) 10552 (and (string-match "\\+" line) (setq line (replace-match "|" t t line)))
10236 (beginning-of-line (if arg 1 2)) 10553 (beginning-of-line (if arg 1 2))
10237 (insert line "\n") 10554 (insert line "\n")
11774 (text nil) 12091 (text nil)
11775 p key val text options) 12092 p key val text options)
11776 (while (re-search-forward re nil t) 12093 (while (re-search-forward re nil t)
11777 (setq key (org-match-string-no-properties 1) 12094 (setq key (org-match-string-no-properties 1)
11778 val (org-match-string-no-properties 2)) 12095 val (org-match-string-no-properties 2))
11779 (cond 12096 (cond
11780 ((string-equal key "TITLE") (setq p (plist-put p :title val))) 12097 ((string-equal key "TITLE") (setq p (plist-put p :title val)))
11781 ((string-equal key "AUTHOR")(setq p (plist-put p :author val))) 12098 ((string-equal key "AUTHOR")(setq p (plist-put p :author val)))
11782 ((string-equal key "EMAIL") (setq p (plist-put p :email val))) 12099 ((string-equal key "EMAIL") (setq p (plist-put p :email val)))
11783 ((string-equal key "LANGUAGE") (setq p (plist-put p :language val))) 12100 ((string-equal key "LANGUAGE") (setq p (plist-put p :language val)))
11784 ((string-equal key "TEXT") 12101 ((string-equal key "TEXT")
11787 (setq p (plist-put p :text text)) 12104 (setq p (plist-put p :text text))
11788 (when options 12105 (when options
11789 (let ((op '(("H" . :headline-levels) 12106 (let ((op '(("H" . :headline-levels)
11790 ("num" . :section-numbers) 12107 ("num" . :section-numbers)
11791 ("toc" . :table-of-contents) 12108 ("toc" . :table-of-contents)
11792 ("\\n" . :preserve-breaks) 12109 ("\\n" . :preserve-breaks)
11793 ("@" . :expand-quoted-html) 12110 ("@" . :expand-quoted-html)
11794 (":" . :fixed-width) 12111 (":" . :fixed-width)
11795 ("|" . :tables) 12112 ("|" . :tables)
11796 ("^" . :sub-superscript) 12113 ("^" . :sub-superscript)
11797 ("*" . :emphasize) 12114 ("*" . :emphasize)
11798 ("TeX" . :TeX-macros))) 12115 ("TeX" . :TeX-macros)))
11799 o) 12116 o)
11800 (while (setq o (pop op)) 12117 (while (setq o (pop op))
11801 (if (string-match (concat (regexp-quote (car o)) 12118 (if (string-match (concat (regexp-quote (car o))
11802 ":\\([^ \t\n\r;,.]*\\)") 12119 ":\\([^ \t\n\r;,.]*\\)")
11803 options) 12120 options)
11804 (setq p (plist-put p (cdr o) 12121 (setq p (plist-put p (cdr o)
11805 (car (read-from-string 12122 (car (read-from-string
11806 (match-string 1 options))))))))) 12123 (match-string 1 options)))))))))
11860 (not (string-match "| *[^ <|]" line))))) 12177 (not (string-match "| *[^ <|]" line)))))
11861 ;; a special table line that should be removed 12178 ;; a special table line that should be removed
11862 ) 12179 )
11863 (t (setq rtn (cons line rtn))))) 12180 (t (setq rtn (cons line rtn)))))
11864 (nreverse rtn))) 12181 (nreverse rtn)))
12182
12183 (defun org-export (&optional arg)
12184 (interactive)
12185 (let ((help "[t] insert the export option template
12186 \[v] limit export to visible part of outline tree
12187
12188 \[a] export as ASCII
12189 \[h] export as HTML
12190 \[b] export as HTML and browse immediately
12191 \[x] export as XOXO
12192
12193 \[i] export current file as iCalendar file
12194 \[I] export all agenda files as iCalendar files
12195 \[c] export agenda files into combined iCalendar file
12196
12197 \[F] publish current file
12198 \[P] publish current project
12199 \[X] publish... (project will be prompted for)
12200 \[A] publish all projects")
12201 (cmds
12202 '((?v . org-export-visible)
12203 (?a . org-export-as-ascii)
12204 (?h . org-export-as-html)
12205 (?b . org-export-as-html-and-open)
12206 (?x . org-export-as-xoxo)
12207 (?i . org-export-icalendar-this-file)
12208 (?I . org-export-icalendar-all-agenda-files)
12209 (?c . org-export-icalendar-combine-agenda-files)
12210 (?F . org-publish-current-file)
12211 (?P . org-publish-current-project)
12212 (?X . org-publish)
12213 (?A . org-publish-all)))
12214 r1 r2 ass)
12215 (save-window-excursion
12216 (delete-other-windows)
12217 (with-output-to-temp-buffer "*Org Export/Publishing Help*"
12218 (princ help))
12219 (message "Select command: ")
12220 (setq r1 (read-char-exclusive)))
12221 (setq r2 (if (< r1 27) (+ r1 96) r1))
12222 (if (setq ass (assq r2 cmds))
12223 (call-interactively (cdr ass))
12224 (error "No command associated with key %c" r1))))
11865 12225
11866 ;; ASCII 12226 ;; ASCII
11867 12227
11868 (defconst org-html-entities 12228 (defconst org-html-entities
11869 '(("nbsp") 12229 '(("nbsp")
12161 In that case, \"\\ent\" will be translated to \"&other;\". 12521 In that case, \"\\ent\" will be translated to \"&other;\".
12162 The list contains HTML entities for Latin-1, Greek and other symbols. 12522 The list contains HTML entities for Latin-1, Greek and other symbols.
12163 It is supplemented by a number of commonly used TeX macros with appropriate 12523 It is supplemented by a number of commonly used TeX macros with appropriate
12164 translations. There is currently no way for users to extend this.") 12524 translations. There is currently no way for users to extend this.")
12165 12525
12166 (defun org-cleaned-string-for-export (string) 12526 (defun org-cleaned-string-for-export (string &rest parameters)
12167 "Cleanup a buffer substring so that links can be created safely." 12527 "Cleanup a buffer substring so that links can be created safely."
12168 (interactive) 12528 (interactive)
12169 (let* ((cb (current-buffer)) 12529 (let* ((cb (current-buffer))
12170 (re-radio (and org-target-link-regexp 12530 (re-radio (and org-target-link-regexp
12171 (concat "\\([^<]\\)\\(" org-target-link-regexp "\\)"))) 12531 (concat "\\([^<]\\)\\(" org-target-link-regexp "\\)")))
12194 (goto-char (match-beginning 0))) 12554 (goto-char (match-beginning 0)))
12195 ;; Normalize links: Convert angle and plain links into bracket links 12555 ;; Normalize links: Convert angle and plain links into bracket links
12196 (goto-char (point-min)) 12556 (goto-char (point-min))
12197 (while (re-search-forward re-plain-link nil t) 12557 (while (re-search-forward re-plain-link nil t)
12198 (replace-match 12558 (replace-match
12199 (concat 12559 (concat
12200 (match-string 1) "[[" (match-string 2) ":" (match-string 3) "]]") 12560 (match-string 1) "[[" (match-string 2) ":" (match-string 3) "]]")
12201 t t)) 12561 t t))
12202 (goto-char (point-min)) 12562 (goto-char (point-min))
12203 (while (re-search-forward re-angle-link nil t) 12563 (while (re-search-forward re-angle-link nil t)
12204 (replace-match 12564 (replace-match
12205 (concat 12565 (concat
12206 (match-string 1) "[[" (match-string 2) ":" (match-string 3) "]]") 12566 (match-string 1) "[[" (match-string 2) ":" (match-string 3) "]]")
12207 t t)) 12567 t t))
12568 ;; Find multiline emphasis and put them into single line
12569 (when (assq :emph-multiline parameters)
12570 (goto-char (point-min))
12571 (while (re-search-forward org-emph-re nil t)
12572 (subst-char-in-region (match-beginning 0) (match-end 0) ?\n ?\ t)
12573 (goto-char (1- (match-end 0)))))
12208 12574
12209 ;; Remove comments 12575 ;; Remove comments
12210 (goto-char (point-min)) 12576 (goto-char (point-min))
12211 (while (re-search-forward "^#.*\n?" nil t) 12577 (while (re-search-forward "^#.*\n?" nil t)
12212 (replace-match "")) 12578 (replace-match ""))
12291 (level 0) line txt 12657 (level 0) line txt
12292 (umax nil) 12658 (umax nil)
12293 (case-fold-search nil) 12659 (case-fold-search nil)
12294 (filename (concat (file-name-as-directory 12660 (filename (concat (file-name-as-directory
12295 (org-export-directory :ascii opt-plist)) 12661 (org-export-directory :ascii opt-plist))
12296 (file-name-sans-extension 12662 (file-name-sans-extension
12297 (file-name-nondirectory buffer-file-name)) 12663 (file-name-nondirectory buffer-file-name))
12298 ".txt")) 12664 ".txt"))
12299 (buffer (find-file-noselect filename)) 12665 (buffer (find-file-noselect filename))
12300 (levels-open (make-vector org-level-max nil)) 12666 (levels-open (make-vector org-level-max nil))
12301 (odd org-odd-levels-only) 12667 (odd org-odd-levels-only)
12325 (erase-buffer) 12691 (erase-buffer)
12326 (fundamental-mode) 12692 (fundamental-mode)
12327 ;; create local variables for all options, to make sure all called 12693 ;; create local variables for all options, to make sure all called
12328 ;; functions get the correct information 12694 ;; functions get the correct information
12329 (mapcar (lambda (x) 12695 (mapcar (lambda (x)
12330 (set (make-local-variable (cdr x)) 12696 (set (make-local-variable (cdr x))
12331 (plist-get opt-plist (car x)))) 12697 (plist-get opt-plist (car x))))
12332 org-export-plist-vars) 12698 org-export-plist-vars)
12333 (set (make-local-variable 'org-odd-levels-only) odd) 12699 (set (make-local-variable 'org-odd-levels-only) odd)
12334 (setq umax (if arg (prefix-numeric-value arg) 12700 (setq umax (if arg (prefix-numeric-value arg)
12335 org-export-headline-levels)) 12701 org-export-headline-levels))
12399 ((string-match "^\\(\\*+\\)[ \t]*\\(.*\\)" line) 12765 ((string-match "^\\(\\*+\\)[ \t]*\\(.*\\)" line)
12400 ;; a Headline 12766 ;; a Headline
12401 (setq level (org-tr-level (- (match-end 1) (match-beginning 1))) 12767 (setq level (org-tr-level (- (match-end 1) (match-beginning 1)))
12402 txt (match-string 2 line)) 12768 txt (match-string 2 line))
12403 (org-ascii-level-start level txt umax lines)) 12769 (org-ascii-level-start level txt umax lines))
12404 (t 12770 (t
12405 (insert (org-fix-indentation line org-ascii-current-indentation) "\n")))) 12771 (insert (org-fix-indentation line org-ascii-current-indentation) "\n"))))
12406 (normal-mode) 12772 (normal-mode)
12407 (save-buffer) 12773 (save-buffer)
12408 ;; remove display and invisible chars 12774 ;; remove display and invisible chars
12409 (let (beg end s) 12775 (let (beg end s)
12457 (defun org-ascii-level-start (level title umax &optional lines) 12823 (defun org-ascii-level-start (level title umax &optional lines)
12458 "Insert a new level in ASCII export." 12824 "Insert a new level in ASCII export."
12459 (let (char (n (- level umax 1)) (ind 0)) 12825 (let (char (n (- level umax 1)) (ind 0))
12460 (if (> level umax) 12826 (if (> level umax)
12461 (progn 12827 (progn
12462 (insert (make-string (* 2 n) ?\ ) 12828 (insert (make-string (* 2 n) ?\ )
12463 (char-to-string (nth (% n (length org-export-ascii-bullets)) 12829 (char-to-string (nth (% n (length org-export-ascii-bullets))
12464 org-export-ascii-bullets)) 12830 org-export-ascii-bullets))
12465 " " title "\n") 12831 " " title "\n")
12466 ;; find the indentation of the next non-empty line 12832 ;; find the indentation of the next non-empty line
12467 (catch 'stop 12833 (catch 'stop
12487 run the export command - in interactive use, the command prompts for this 12853 run the export command - in interactive use, the command prompts for this
12488 key. As a special case, if the you type SPC at the prompt, the temporary 12854 key. As a special case, if the you type SPC at the prompt, the temporary
12489 org-mode file will not be removed but presented to you so that you can 12855 org-mode file will not be removed but presented to you so that you can
12490 continue to use it. The prefix arg ARG is passed through to the exporting 12856 continue to use it. The prefix arg ARG is passed through to the exporting
12491 command." 12857 command."
12492 (interactive 12858 (interactive
12493 (list (progn 12859 (list (progn
12494 (message "Export visible: [a]SCII [h]tml [b]rowse HTML [x]OXO [ ]keep buffer") 12860 (message "Export visible: [a]SCII [h]tml [b]rowse HTML [x]OXO [ ]keep buffer")
12495 (char-to-string (read-char-exclusive))) 12861 (char-to-string (read-char-exclusive)))
12496 current-prefix-arg)) 12862 current-prefix-arg))
12497 (if (not (member type '("a" "\C-a" "b" "\C-b" "h" "x" " "))) 12863 (if (not (member type '("a" "\C-a" "b" "\C-b" "h" "x" " ")))
12498 (error "Invalid export key")) 12864 (error "Invalid export key"))
12865 ;; FIXME: do this more explicit?
12499 (let* ((binding (key-binding (concat "\C-c\C-x" type))) 12866 (let* ((binding (key-binding (concat "\C-c\C-x" type)))
12500 (keepp (equal type " ")) 12867 (keepp (equal type " "))
12501 (file buffer-file-name) 12868 (file buffer-file-name)
12502 (buffer (get-buffer-create "*Org Export Visible*")) 12869 (buffer (get-buffer-create "*Org Export Visible*"))
12503 s e) 12870 s e)
12678 (setq-default org-deadline-line-regexp org-deadline-line-regexp) 13045 (setq-default org-deadline-line-regexp org-deadline-line-regexp)
12679 (setq-default org-done-string org-done-string) 13046 (setq-default org-done-string org-done-string)
12680 (let* ((opt-plist (org-combine-plists (org-default-export-plist) 13047 (let* ((opt-plist (org-combine-plists (org-default-export-plist)
12681 ext-plist 13048 ext-plist
12682 (org-infile-export-plist))) 13049 (org-infile-export-plist)))
12683 13050
12684 (style (plist-get opt-plist :style)) 13051 (style (plist-get opt-plist :style))
12685 (odd org-odd-levels-only) 13052 (odd org-odd-levels-only)
12686 (region-p (org-region-active-p)) 13053 (region-p (org-region-active-p))
12687 (region 13054 (region
12688 (buffer-substring 13055 (buffer-substring
12689 (if region-p (region-beginning) (point-min)) 13056 (if region-p (region-beginning) (point-min))
12690 (if region-p (region-end) (point-max)))) 13057 (if region-p (region-end) (point-max))))
12691 (all_lines 13058 (all_lines
12692 (org-skip-comments (org-split-string 13059 (org-skip-comments (org-split-string
12693 (org-cleaned-string-for-export region) 13060 (org-cleaned-string-for-export
13061 region :emph-multiline)
12694 "[\r\n]"))) 13062 "[\r\n]")))
12695 (lines (org-export-find-first-heading-line all_lines)) 13063 (lines (org-export-find-first-heading-line all_lines))
12696 (level 0) (line "") (origline "") txt todo 13064 (level 0) (line "") (origline "") txt todo
12697 (umax nil) 13065 (umax nil)
12698 (filename (concat (file-name-as-directory 13066 (filename (concat (file-name-as-directory
12699 (org-export-directory :html opt-plist)) 13067 (org-export-directory :html opt-plist))
12700 (file-name-sans-extension 13068 (file-name-sans-extension
12701 (file-name-nondirectory buffer-file-name)) 13069 (file-name-nondirectory buffer-file-name))
12702 ".html")) 13070 ".html"))
12703 (buffer (find-file-noselect filename)) 13071 (buffer (find-file-noselect filename))
12704 (levels-open (make-vector org-level-max nil)) 13072 (levels-open (make-vector org-level-max nil))
12705 (date (format-time-string "%Y/%m/%d" (current-time))) 13073 (date (format-time-string "%Y/%m/%d" (current-time)))
12753 (let ((case-fold-search nil) 13121 (let ((case-fold-search nil)
12754 (org-odd-levels-only odd)) 13122 (org-odd-levels-only odd))
12755 ;; create local variables for all options, to make sure all called 13123 ;; create local variables for all options, to make sure all called
12756 ;; functions get the correct information 13124 ;; functions get the correct information
12757 (mapcar (lambda (x) 13125 (mapcar (lambda (x)
12758 (set (make-local-variable (cdr x)) 13126 (set (make-local-variable (cdr x))
12759 (plist-get opt-plist (car x)))) 13127 (plist-get opt-plist (car x))))
12760 org-export-plist-vars) 13128 org-export-plist-vars)
12761 (setq umax (if arg (prefix-numeric-value arg) 13129 (setq umax (if arg (prefix-numeric-value arg)
12762 org-export-headline-levels)) 13130 org-export-headline-levels))
12763 13131
12944 thefile file-is-image-p search) 13312 thefile file-is-image-p search)
12945 (save-match-data 13313 (save-match-data
12946 (if (string-match "::\\(.*\\)" filename) 13314 (if (string-match "::\\(.*\\)" filename)
12947 (setq search (match-string 1 filename) 13315 (setq search (match-string 1 filename)
12948 filename (replace-match "" t nil filename))) 13316 filename (replace-match "" t nil filename)))
12949 (setq file-is-image-p 13317 (setq file-is-image-p
12950 (string-match (org-image-file-name-regexp) filename)) 13318 (string-match (org-image-file-name-regexp) filename))
12951 (setq thefile (if abs-p (expand-file-name filename) filename)) 13319 (setq thefile (if abs-p (expand-file-name filename) filename))
12952 (when (and org-export-html-link-org-files-as-html 13320 (when (and org-export-html-link-org-files-as-html
12953 (string-match "\\.org$" thefile)) 13321 (string-match "\\.org$" thefile))
12954 (setq thefile (concat (substring thefile 0 13322 (setq thefile (concat (substring thefile 0
12957 (if (and search 13325 (if (and search
12958 ;; make sure this is can be used as target search 13326 ;; make sure this is can be used as target search
12959 (not (string-match "^[0-9]*$" search)) 13327 (not (string-match "^[0-9]*$" search))
12960 (not (string-match "^\\*" search)) 13328 (not (string-match "^\\*" search))
12961 (not (string-match "^/.*/$" search))) 13329 (not (string-match "^/.*/$" search)))
12962 (setq thefile (concat thefile "#" 13330 (setq thefile (concat thefile "#"
12963 (org-solidify-link-text 13331 (org-solidify-link-text
12964 (org-link-unescape search))))) 13332 (org-link-unescape search)))))
12965 (when (string-match "^file:" desc) 13333 (when (string-match "^file:" desc)
12966 (setq desc (replace-match "" t t desc)) 13334 (setq desc (replace-match "" t t desc))
12967 (if (string-match "\\.org$" desc) 13335 (if (string-match "\\.org$" desc)
13037 ((= llt ?\)) "^\\( \t]*\\)\\(\\([-+*]\\)\\|\\([0-9]+)\\) \\)?\\( *[^ \t\n\r]\\|[ \t]*$\\)") 13405 ((= llt ?\)) "^\\( \t]*\\)\\(\\([-+*]\\)\\|\\([0-9]+)\\) \\)?\\( *[^ \t\n\r]\\|[ \t]*$\\)")
13038 (t (error "Invalid value of `org-plain-list-ordered-item-terminator'"))) 13406 (t (error "Invalid value of `org-plain-list-ordered-item-terminator'")))
13039 line) 13407 line)
13040 (setq ind (org-get-string-indentation line) 13408 (setq ind (org-get-string-indentation line)
13041 start-is-num (match-beginning 4) 13409 start-is-num (match-beginning 4)
13042 starter (if (match-beginning 2) 13410 starter (if (match-beginning 2)
13043 (substring (match-string 2 line) 0 -1)) 13411 (substring (match-string 2 line) 0 -1))
13044 line (substring line (match-beginning 5))) 13412 line (substring line (match-beginning 5)))
13045 (unless (string-match "[^ \t]" line) 13413 (unless (string-match "[^ \t]" line)
13046 ;; empty line. Pretend indentation is large. 13414 ;; empty line. Pretend indentation is large.
13047 (setq ind (1+ (or (car local-list-indent) 1)))) 13415 (setq ind (1+ (or (car local-list-indent) 1))))
13066 (starter 13434 (starter
13067 ;; continue current list 13435 ;; continue current list
13068 (org-close-li) 13436 (org-close-li)
13069 (insert "<li>\n"))) 13437 (insert "<li>\n")))
13070 (if (string-match "^[ \t]*\\[\\([X ]\\)\\]" line) 13438 (if (string-match "^[ \t]*\\[\\([X ]\\)\\]" line)
13071 (setq line 13439 (setq line
13072 (replace-match 13440 (replace-match
13073 (if (equal (match-string 1 line) "X") 13441 (if (equal (match-string 1 line) "X")
13074 "<b>[X]</b>" 13442 "<b>[X]</b>"
13075 "<b>[<span style=\"visibility:hidden;\">X</span>]</b>") 13443 "<b>[<span style=\"visibility:hidden;\">X</span>]</b>")
13076 t t line)))) 13444 t t line))))
13086 (setq line (replace-match "<br/>" t t line))) 13454 (setq line (replace-match "<br/>" t t line)))
13087 (org-export-preserve-breaks 13455 (org-export-preserve-breaks
13088 (setq line (concat line "<br/>")))) 13456 (setq line (concat line "<br/>"))))
13089 13457
13090 (insert line "\n"))))) 13458 (insert line "\n")))))
13091 13459
13092 ;; Properly close all local lists and other lists 13460 ;; Properly close all local lists and other lists
13093 (when inquote (insert "</pre>\n")) 13461 (when inquote (insert "</pre>\n"))
13094 (when in-local-list 13462 (when in-local-list
13095 ;; Close any local lists before inserting a new header line 13463 ;; Close any local lists before inserting a new header line
13096 (while local-list-num 13464 (while local-list-num
13113 (insert "</p>\n")) 13481 (insert "</p>\n"))
13114 (when (and date time) 13482 (when (and date time)
13115 (insert "<p class=\"date\"> " 13483 (insert "<p class=\"date\"> "
13116 (nth 2 lang-words) ": " 13484 (nth 2 lang-words) ": "
13117 date " " time "</p>\n"))) 13485 date " " time "</p>\n")))
13118 13486
13119 (if org-export-html-with-timestamp 13487 (if org-export-html-with-timestamp
13120 (insert org-export-html-html-helper-timestamp)) 13488 (insert org-export-html-html-helper-timestamp))
13121 (insert (or (plist-get opt-plist :postamble) "")) 13489 (insert (or (plist-get opt-plist :postamble) ""))
13122 (insert "</body>\n</html>\n") 13490 (insert "</body>\n</html>\n")
13123 (normal-mode) 13491 (normal-mode)
13286 (while (string-match org-maybe-keyword-time-regexp s) 13654 (while (string-match org-maybe-keyword-time-regexp s)
13287 (or b (setq b (substring s 0 (match-beginning 0)))) 13655 (or b (setq b (substring s 0 (match-beginning 0))))
13288 (if (not org-export-with-timestamps) 13656 (if (not org-export-with-timestamps)
13289 (setq r (concat r (substring s 0 (match-beginning 0))) 13657 (setq r (concat r (substring s 0 (match-beginning 0)))
13290 s (substring s (match-end 0))) 13658 s (substring s (match-end 0)))
13291 (setq r (concat 13659 (setq r (concat
13292 r (substring s 0 (match-beginning 0)) 13660 r (substring s 0 (match-beginning 0))
13293 (if (match-end 1) 13661 (if (match-end 1)
13294 (format "@<span class=\"timestamp-kwd\">%s @</span>" 13662 (format "@<span class=\"timestamp-kwd\">%s @</span>"
13295 (match-string 1 s))) 13663 (match-string 1 s)))
13296 (format " @<span class=\"timestamp\">%s@</span>" 13664 (format " @<span class=\"timestamp\">%s@</span>"
13297 (substring (match-string 3 s) 1 -1))) 13665 (substring (match-string 3 s) 1 -1)))
13298 s (substring s (match-end 0))))) 13666 s (substring s (match-end 0)))))
13401 (while (string-match "\\\\\\([_^]\\)" string) 13769 (while (string-match "\\\\\\([_^]\\)" string)
13402 (setq string (replace-match (match-string 1 string) t t string)))) 13770 (setq string (replace-match (match-string 1 string) t t string))))
13403 string) 13771 string)
13404 13772
13405 (defun org-export-html-convert-emphasize (string) 13773 (defun org-export-html-convert-emphasize (string)
13406 (while (string-match org-italic-re string) 13774 "Apply emphasis."
13407 (setq string (replace-match "\\1<i>\\3</i>\\4" t nil string))) 13775 (while (string-match org-emph-re string)
13408 (while (string-match org-bold-re string) 13776 (setq string (replace-match (concat "\\1" (nth 2 (assoc (match-string 3 string) org-emphasis-alist)) "\\4" (nth 3 (assoc (match-string 3 string) org-emphasis-alist)) "\\5") t nil string)))
13409 (setq string (replace-match "\\1<b>\\3</b>\\4" t nil string)))
13410 (while (string-match org-underline-re string)
13411 (setq string (replace-match "\\1<u>\\3</u>\\4" t nil string)))
13412 string) 13777 string)
13413 13778
13414 (defvar org-par-open nil) 13779 (defvar org-par-open nil)
13415 (defun org-open-par () 13780 (defun org-open-par ()
13416 "Insert <p>, but first close previous paragraph if any." 13781 "Insert <p>, but first close previous paragraph if any."
13444 (setq l (1+ l))) 13809 (setq l (1+ l)))
13445 (when title 13810 (when title
13446 ;; If title is nil, this means this function is called to close 13811 ;; If title is nil, this means this function is called to close
13447 ;; all levels, so the rest is done only if title is given 13812 ;; all levels, so the rest is done only if title is given
13448 (when (string-match "\\(:[a-zA-Z0-9_@:]+:\\)[ \t]*$" title) 13813 (when (string-match "\\(:[a-zA-Z0-9_@:]+:\\)[ \t]*$" title)
13449 (setq title (replace-match 13814 (setq title (replace-match
13450 (if org-export-with-tags 13815 (if org-export-with-tags
13451 (save-match-data 13816 (save-match-data
13452 (concat 13817 (concat
13453 "&nbsp;&nbsp;&nbsp;<span class=\"tag\">" 13818 "&nbsp;&nbsp;&nbsp;<span class=\"tag\">"
13454 (mapconcat 'identity (org-split-string 13819 (mapconcat 'identity (org-split-string
13455 (match-string 1 title) ":") 13820 (match-string 1 title) ":")
13456 "&nbsp;") 13821 "&nbsp;")
13457 "</span>")) 13822 "</span>"))
13458 "") 13823 "")
13459 t t title))) 13824 t t title)))
13525 (if (string-match "\\(\\.0\\)+\\'" string) 13890 (if (string-match "\\(\\.0\\)+\\'" string)
13526 (setq string (replace-match "" t nil string)))) 13891 (setq string (replace-match "" t nil string))))
13527 string)) 13892 string))
13528 13893
13529 13894
13895 ;;;###autoload
13530 (defun org-export-icalendar-this-file () 13896 (defun org-export-icalendar-this-file ()
13531 "Export current file as an iCalendar file. 13897 "Export current file as an iCalendar file.
13532 The iCalendar file will be located in the same directory as the Org-mode 13898 The iCalendar file will be located in the same directory as the Org-mode
13533 file, but with extension `.ics'." 13899 file, but with extension `.ics'."
13534 (interactive) 13900 (interactive)
13549 (goto-char (point-min)) ;; CD: beginning-of-buffer is not allowed. 13915 (goto-char (point-min)) ;; CD: beginning-of-buffer is not allowed.
13550 (let* ((opt-plist (org-combine-plists (org-default-export-plist) 13916 (let* ((opt-plist (org-combine-plists (org-default-export-plist)
13551 (org-infile-export-plist))) 13917 (org-infile-export-plist)))
13552 (filename (concat (file-name-as-directory 13918 (filename (concat (file-name-as-directory
13553 (org-export-directory :xoxo opt-plist)) 13919 (org-export-directory :xoxo opt-plist))
13554 (file-name-sans-extension 13920 (file-name-sans-extension
13555 (file-name-nondirectory buffer-file-name)) 13921 (file-name-nondirectory buffer-file-name))
13556 ".html")) 13922 ".html"))
13557 (out (find-file-noselect filename)) 13923 (out (find-file-noselect filename))
13558 (last-level 1) 13924 (last-level 1)
13559 (hanging-li nil)) 13925 (hanging-li nil))
13634 (defun org-export-icalendar (combine &rest files) 14000 (defun org-export-icalendar (combine &rest files)
13635 "Create iCalendar files for all elements of FILES. 14001 "Create iCalendar files for all elements of FILES.
13636 If COMBINE is non-nil, combine all calendar entries into a single large 14002 If COMBINE is non-nil, combine all calendar entries into a single large
13637 file and store it under the name `org-combined-agenda-icalendar-file'." 14003 file and store it under the name `org-combined-agenda-icalendar-file'."
13638 (save-excursion 14004 (save-excursion
13639 (let* ((dir (org-export-directory 14005 (let* ((dir (org-export-directory
13640 :ical (list :publishing-directory 14006 :ical (list :publishing-directory
13641 org-export-publishing-directory))) 14007 org-export-publishing-directory)))
13642 file ical-file ical-buffer category started org-agenda-new-buffers) 14008 file ical-file ical-buffer category started org-agenda-new-buffers)
13643 14009
13644 (when combine 14010 (when combine
13645 (setq ical-file 14011 (setq ical-file
13646 (if (file-name-absolute-p org-combined-agenda-icalendar-file) 14012 (if (file-name-absolute-p org-combined-agenda-icalendar-file)
13647 org-combined-agenda-icalendar-file 14013 org-combined-agenda-icalendar-file
13648 (expand-file-name org-combined-agenda-icalendar-file dir)) 14014 (expand-file-name org-combined-agenda-icalendar-file dir))
13652 (catch 'nextfile 14018 (catch 'nextfile
13653 (org-check-agenda-file file) 14019 (org-check-agenda-file file)
13654 (set-buffer (org-get-agenda-file-buffer file)) 14020 (set-buffer (org-get-agenda-file-buffer file))
13655 (unless combine 14021 (unless combine
13656 (setq ical-file (concat (file-name-as-directory dir) 14022 (setq ical-file (concat (file-name-as-directory dir)
13657 (file-name-sans-extension 14023 (file-name-sans-extension
13658 (file-name-nondirectory buffer-file-name)) 14024 (file-name-nondirectory buffer-file-name))
13659 ".ics")) 14025 ".ics"))
13660 (setq ical-buffer (org-get-agenda-file-buffer ical-file)) 14026 (setq ical-buffer (org-get-agenda-file-buffer ical-file))
13661 (with-current-buffer ical-buffer (erase-buffer))) 14027 (with-current-buffer ical-buffer (erase-buffer)))
13662 (setq category (or org-category 14028 (setq category (or org-category
13791 ;; i k @ expendable from outline-mode 14157 ;; i k @ expendable from outline-mode
13792 ;; 0123456789 % & ()_{} " ` free 14158 ;; 0123456789 % & ()_{} " ` free
13793 14159
13794 ;; Make `C-c C-x' a prefix key 14160 ;; Make `C-c C-x' a prefix key
13795 (define-key org-mode-map "\C-c\C-x" (make-sparse-keymap)) 14161 (define-key org-mode-map "\C-c\C-x" (make-sparse-keymap))
13796 (define-key org-mode-map "\C-c\C-e" (make-sparse-keymap))
13797 14162
13798 ;; TAB key with modifiers 14163 ;; TAB key with modifiers
13799 (define-key org-mode-map "\C-i" 'org-cycle) 14164 (define-key org-mode-map "\C-i" 'org-cycle)
13800 (define-key org-mode-map [(tab)] 'org-cycle) 14165 (define-key org-mode-map [(tab)] 'org-cycle)
13801 (define-key org-mode-map [(meta tab)] 'org-complete) 14166 (define-key org-mode-map [(meta tab)] 'org-complete)
13887 (define-key org-mode-map "\C-c|" 'org-table-create-or-convert-from-region) 14252 (define-key org-mode-map "\C-c|" 'org-table-create-or-convert-from-region)
13888 (define-key org-mode-map "\C-c*" 'org-table-recalculate) 14253 (define-key org-mode-map "\C-c*" 'org-table-recalculate)
13889 (define-key org-mode-map [(control ?#)] 'org-table-rotate-recalc-marks) 14254 (define-key org-mode-map [(control ?#)] 'org-table-rotate-recalc-marks)
13890 (define-key org-mode-map "\C-c~" 'org-table-create-with-table.el) 14255 (define-key org-mode-map "\C-c~" 'org-table-create-with-table.el)
13891 (define-key org-mode-map "\C-c\C-q" 'org-table-wrap-region) 14256 (define-key org-mode-map "\C-c\C-q" 'org-table-wrap-region)
13892 (define-key org-mode-map "\C-c\C-xa" 'org-export-as-ascii) 14257 (define-key org-mode-map "\C-c\C-e" 'org-export)
13893 (define-key org-mode-map "\C-c\C-x\C-a" 'org-export-as-ascii) 14258 ;(define-key org-mode-map "\C-c\C-xa" 'org-export-as-ascii)
13894 (define-key org-mode-map "\C-c\C-xv" 'org-export-visible) 14259 ;(define-key org-mode-map "\C-c\C-x\C-a" 'org-export-as-ascii)
13895 (define-key org-mode-map "\C-c\C-x\C-v" 'org-export-visible) 14260 ;(define-key org-mode-map "\C-c\C-xv" 'org-export-visible)
14261 ;(define-key org-mode-map "\C-c\C-x\C-v" 'org-export-visible)
13896 ;; OPML support is only an option for the future 14262 ;; OPML support is only an option for the future
13897 ;(define-key org-mode-map "\C-c\C-xo" 'org-export-as-opml) 14263 ;(define-key org-mode-map "\C-c\C-xo" 'org-export-as-opml)
13898 ;(define-key org-mode-map "\C-c\C-x\C-o" 'org-export-as-opml) 14264 ;(define-key org-mode-map "\C-c\C-x\C-o" 'org-export-as-opml)
13899 (define-key org-mode-map "\C-c\C-xi" 'org-export-icalendar-this-file) 14265 ;(define-key org-mode-map "\C-c\C-xi" 'org-export-icalendar-this-file)
13900 (define-key org-mode-map "\C-c\C-x\C-i" 'org-export-icalendar-all-agenda-files) 14266 ;(define-key org-mode-map "\C-c\C-x\C-i" 'org-export-icalendar-all-agenda-files)
13901 (define-key org-mode-map "\C-c\C-xc" 'org-export-icalendar-combine-agenda-files) 14267 ;(define-key org-mode-map "\C-c\C-xc" 'org-export-icalendar-combine-agenda-files)
13902 (define-key org-mode-map "\C-c\C-x\C-c" 'org-export-icalendar-combine-agenda-files) 14268 ;(define-key org-mode-map "\C-c\C-x\C-c" 'org-export-icalendar-combine-agenda-files)
13903 (define-key org-mode-map "\C-c\C-xt" 'org-insert-export-options-template) 14269 ;(define-key org-mode-map "\C-c\C-xt" 'org-insert-export-options-template)
13904 (define-key org-mode-map "\C-c:" 'org-toggle-fixed-width-section) 14270 (define-key org-mode-map "\C-c:" 'org-toggle-fixed-width-section)
13905 (define-key org-mode-map "\C-c\C-xh" 'org-export-as-html) 14271 ;(define-key org-mode-map "\C-c\C-xh" 'org-export-as-html)
13906 (define-key org-mode-map "\C-c\C-xx" 'org-export-as-xoxo) 14272 ;(define-key org-mode-map "\C-c\C-xx" 'org-export-as-xoxo)
13907 (define-key org-mode-map "\C-c\C-x\C-x" 'org-export-as-xoxo) 14273 ;(define-key org-mode-map "\C-c\C-x\C-x" 'org-export-as-xoxo)
13908 (define-key org-mode-map "\C-c\C-xb" 'org-export-as-html-and-open) 14274 ;(define-key org-mode-map "\C-c\C-xb" 'org-export-as-html-and-open)
13909 (define-key org-mode-map "\C-c\C-x\C-b" 'org-export-as-html-and-open) 14275 ;(define-key org-mode-map "\C-c\C-x\C-b" 'org-export-as-html-and-open)
13910 14276
13911 (define-key org-mode-map "\C-c\C-x\C-k" 'org-cut-special) 14277 (define-key org-mode-map "\C-c\C-x\C-k" 'org-cut-special)
13912 (define-key org-mode-map "\C-c\C-x\C-w" 'org-cut-special) 14278 (define-key org-mode-map "\C-c\C-x\C-w" 'org-cut-special)
13913 (define-key org-mode-map "\C-c\C-x\M-w" 'org-copy-special) 14279 (define-key org-mode-map "\C-c\C-x\M-w" 'org-copy-special)
13914 (define-key org-mode-map "\C-c\C-x\C-y" 'org-paste-special) 14280 (define-key org-mode-map "\C-c\C-x\C-y" 'org-paste-special)
13915 14281
13916 (define-key org-mode-map "\C-c\C-ef" 'org-publish-current-file) 14282 (define-key org-mode-map "\C-c\C-x\C-i" 'org-clock-in)
13917 (define-key org-mode-map "\C-c\C-ep" 'org-publish-current-project) 14283 (define-key org-mode-map "\C-c\C-x\C-o" 'org-clock-out)
13918 (define-key org-mode-map "\C-c\C-ec" 'org-publish) 14284 (define-key org-mode-map "\C-c\C-x\C-x" 'org-clock-cancel)
13919 (define-key org-mode-map "\C-c\C-ea" 'org-publish-all) 14285 (define-key org-mode-map "\C-c\C-x\C-d" 'org-clock-display)
13920 (define-key org-mode-map "\C-c\C-e\C-f" 'org-publish-current-file) 14286
13921 (define-key org-mode-map "\C-c\C-e\C-p" 'org-publish-current-project) 14287 ;(define-key org-mode-map "\C-c\C-ef" 'org-publish-current-file)
13922 (define-key org-mode-map "\C-c\C-e\C-c" 'org-publish) 14288 ;(define-key org-mode-map "\C-c\C-ep" 'org-publish-current-project)
13923 (define-key org-mode-map "\C-c\C-e\C-a" 'org-publish-all) 14289 ;(define-key org-mode-map "\C-c\C-ec" 'org-publish)
13924 14290 ;(define-key org-mode-map "\C-c\C-ea" 'org-publish-all)
13925 (when (featurep 'xemacs) 14291 ;(define-key org-mode-map "\C-c\C-e\C-f" 'org-publish-current-file)
14292 ;(define-key org-mode-map "\C-c\C-e\C-p" 'org-publish-current-project)
14293 ;(define-key org-mode-map "\C-c\C-e\C-c" 'org-publish)
14294 ;(define-key org-mode-map "\C-c\C-e\C-a" 'org-publish-all)
14295
14296 (when (featurep 'xemacs)
13926 (define-key org-mode-map 'button3 'popup-mode-menu)) 14297 (define-key org-mode-map 'button3 'popup-mode-menu))
13927 14298
13928 (defsubst org-table-p () (org-at-table-p)) 14299 (defsubst org-table-p () (org-at-table-p))
13929 14300
13930 (defun org-self-insert-command (N) 14301 (defun org-self-insert-command (N)
13963 (interactive "p") 14334 (interactive "p")
13964 (if (and (org-table-p) 14335 (if (and (org-table-p)
13965 (eq N 1) 14336 (eq N 1)
13966 (string-match "|" (buffer-substring (point-at-bol) (point))) 14337 (string-match "|" (buffer-substring (point-at-bol) (point)))
13967 (looking-at ".*?|")) 14338 (looking-at ".*?|"))
13968 (let ((pos (point)) 14339 (let ((pos (point))
13969 (noalign (looking-at "[^|\n\r]* |")) 14340 (noalign (looking-at "[^|\n\r]* |"))
13970 (c org-table-may-need-update)) 14341 (c org-table-may-need-update))
13971 (backward-delete-char N) 14342 (backward-delete-char N)
13972 (skip-chars-forward "^|") 14343 (skip-chars-forward "^|")
13973 (insert " ") 14344 (insert " ")
14026 14397
14027 (defun org-shiftcursor-error () 14398 (defun org-shiftcursor-error ()
14028 "Throw an error because Shift-Cursor command was applied in wrong context." 14399 "Throw an error because Shift-Cursor command was applied in wrong context."
14029 (error "This command is active in special context like tables, headlines or timestamps")) 14400 (error "This command is active in special context like tables, headlines or timestamps"))
14030 14401
14031 (defun org-shifttab () 14402 (defun org-shifttab (&optional arg)
14032 "Global visibility cycling or move to previous table field. 14403 "Global visibility cycling or move to previous table field.
14033 Calls `org-cycle' with argument t, or `org-table-previous-field', depending 14404 Calls `org-cycle' with argument t, or `org-table-previous-field', depending
14034 on context. 14405 on context.
14035 See the individual commands for more information." 14406 See the individual commands for more information."
14036 (interactive) 14407 (interactive "P")
14037 (cond 14408 (cond
14038 ((org-at-table-p) (call-interactively 'org-table-previous-field)) 14409 ((org-at-table-p) (call-interactively 'org-table-previous-field))
14039 (t (call-interactively 'org-global-cycle)))) 14410 (t (call-interactively 'org-global-cycle))))
14040 14411
14041 (defun org-shiftmetaleft () 14412 (defun org-shiftmetaleft ()
14202 into the current line, aligned to `org-tags-column'. When called 14573 into the current line, aligned to `org-tags-column'. When called
14203 with prefix arg, realign all tags in the current buffer. 14574 with prefix arg, realign all tags in the current buffer.
14204 14575
14205 - If the cursor is in one of the special #+KEYWORD lines, this 14576 - If the cursor is in one of the special #+KEYWORD lines, this
14206 triggers scanning the buffer for these lines and updating the 14577 triggers scanning the buffer for these lines and updating the
14207 information. 14578 information.
14208 14579
14209 - If the cursor is inside a table, realign the table. This command 14580 - If the cursor is inside a table, realign the table. This command
14210 works even if the automatic table editor has been turned off. 14581 works even if the automatic table editor has been turned off.
14211 14582
14212 - If the cursor is on a #+TBLFM line, re-apply the formulas to 14583 - If the cursor is on a #+TBLFM line, re-apply the formulas to
14225 - If the cursor is on a numbered item in a plain list, renumber the 14596 - If the cursor is on a numbered item in a plain list, renumber the
14226 ordered list." 14597 ordered list."
14227 (interactive "P") 14598 (interactive "P")
14228 (let ((org-enable-table-editor t)) 14599 (let ((org-enable-table-editor t))
14229 (cond 14600 (cond
14601 (org-clock-overlays
14602 (org-remove-clock-overlays)
14603 (message "Clock overlays removed"))
14604 (org-occur-highlights
14605 (org-remove-occur-highlights)
14606 (message "occur highlights removed"))
14230 ((and (local-variable-p 'org-finish-function (current-buffer)) 14607 ((and (local-variable-p 'org-finish-function (current-buffer))
14231 (fboundp org-finish-function)) 14608 (fboundp org-finish-function))
14232 (funcall org-finish-function)) 14609 (funcall org-finish-function))
14233 ((org-on-target-p) (call-interactively 'org-update-radio-target-regexp)) 14610 ((org-on-target-p) (call-interactively 'org-update-radio-target-regexp))
14234 ((org-on-heading-p) (call-interactively 'org-set-tags)) 14611 ((org-on-heading-p) (call-interactively 'org-set-tags))
14401 ["Schedule Item" org-schedule t] 14778 ["Schedule Item" org-schedule t]
14402 ["Deadline" org-deadline t] 14779 ["Deadline" org-deadline t]
14403 "--" 14780 "--"
14404 ["Goto Calendar" org-goto-calendar t] 14781 ["Goto Calendar" org-goto-calendar t]
14405 ["Date from Calendar" org-date-from-calendar t]) 14782 ["Date from Calendar" org-date-from-calendar t])
14783 ("Logging work"
14784 ["Clock in" org-clock-in t]
14785 ["Clock out" org-clock-out t]
14786 ["Clock cancel" org-clock-cancel t]
14787 ["Display times" org-clock-display t]
14788 "--"
14789 ["Record DONE time"
14790 (progn (setq org-log-done (not org-log-done))
14791 (message "Switching to %s will %s record a timestamp"
14792 org-done-string
14793 (if org-log-done "automatically" "not")))
14794 :style toggle :selected org-log-done])
14406 "--" 14795 "--"
14407 ["Agenda Command" org-agenda t] 14796 ["Agenda Command" org-agenda t]
14408 ("File List for Agenda") 14797 ("File List for Agenda")
14409 ("Special views current file" 14798 ("Special views current file"
14410 ["TODO Tree" org-show-todo-tree t] 14799 ["TODO Tree" org-show-todo-tree t]
14424 (progn 14813 (progn
14425 (org-remove-from-invisibility-spec '(org-link)) (org-restart-font-lock)) 14814 (org-remove-from-invisibility-spec '(org-link)) (org-restart-font-lock))
14426 :style radio :selected (not (member '(org-link) buffer-invisibility-spec))] 14815 :style radio :selected (not (member '(org-link) buffer-invisibility-spec))]
14427 "--" 14816 "--"
14428 ["Upgrade all <link> to [[link][desc]]" org-upgrade-old-links 14817 ["Upgrade all <link> to [[link][desc]]" org-upgrade-old-links
14429 (save-excursion (goto-char (point-min)) 14818 (save-excursion (goto-char (point-min))
14430 (re-search-forward "<[a-z]+:" nil t))]) 14819 (re-search-forward "<[a-z]+:" nil t))])
14431 "--" 14820 "--"
14432 ("Export" 14821 ["Export/Publish" org-export t]
14433 ["ASCII" org-export-as-ascii t]
14434 ["Export visible part..." org-export-visible t]
14435 ["HTML" org-export-as-html t]
14436 ["HTML and Open" org-export-as-html-and-open t]
14437 ["XOXO" org-export-as-xoxo t]
14438 "--"
14439 ["iCalendar this file" org-export-icalendar-this-file t]
14440 ["iCalendar all agenda files" org-export-icalendar-all-agenda-files
14441 :active t :keys "C-c C-x C-i"]
14442 ["iCalendar combined" org-export-icalendar-combine-agenda-files t]
14443 "--"
14444 ["Option Template" org-insert-export-options-template t]
14445 ["Toggle Fixed Width" org-toggle-fixed-width-section t])
14446 ("Publish"
14447 ["Current File" org-publish-current-file t]
14448 ["Current Project" org-publish-current-project t]
14449 ["Project..." org-publish t]
14450 ["All Projects" org-publish-all t])
14451 "--" 14822 "--"
14452 ("Documentation" 14823 ("Documentation"
14453 ["Show Version" org-version t] 14824 ["Show Version" org-version t]
14454 ["Info Documentation" org-info t]) 14825 ["Info Documentation" org-info t])
14455 ("Customize" 14826 ("Customize"
14647 "\f\\|[ ]*$\\|\\([*\f]+\\)\\|[ \t]*\\([-+*]\\|[0-9]+[.)][ \t]+\\)\\|[ \t]*[:|]") 15018 "\f\\|[ ]*$\\|\\([*\f]+\\)\\|[ \t]*\\([-+*]\\|[0-9]+[.)][ \t]+\\)\\|[ \t]*[:|]")
14648 ;; Inhibit auto-fill for headers, tables and fixed-width lines. 15019 ;; Inhibit auto-fill for headers, tables and fixed-width lines.
14649 ;; But only if the user has not turned off tables or fixed-width regions 15020 ;; But only if the user has not turned off tables or fixed-width regions
14650 (set (make-local-variable 'auto-fill-inhibit-regexp) 15021 (set (make-local-variable 'auto-fill-inhibit-regexp)
14651 (concat "\\*\\|#" 15022 (concat "\\*\\|#"
15023 "\\|[ \t]*" org-keyword-time-regexp
14652 (if (or org-enable-table-editor org-enable-fixed-width-editor) 15024 (if (or org-enable-table-editor org-enable-fixed-width-editor)
14653 (concat 15025 (concat
14654 "\\|[ \t]*[" 15026 "\\|[ \t]*["
14655 (if org-enable-table-editor "|" "") 15027 (if org-enable-table-editor "|" "")
14656 (if org-enable-fixed-width-editor ":" "") 15028 (if org-enable-fixed-width-editor ":" "")
14966 15338
14967 (provide 'org) 15339 (provide 'org)
14968 15340
14969 (run-hooks 'org-load-hook) 15341 (run-hooks 'org-load-hook)
14970 15342
14971
14972 ;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd 15343 ;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd
14973 ;;; org.el ends here 15344 ;;; org.el ends here
14974
14975
14976
14977