aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/textmodes/org.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/textmodes/org.el')
-rw-r--r--lisp/textmodes/org.el578
1 files changed, 307 insertions, 271 deletions
diff --git a/lisp/textmodes/org.el b/lisp/textmodes/org.el
index 4cda0d6b3a0..ecbcd86d043 100644
--- a/lisp/textmodes/org.el
+++ b/lisp/textmodes/org.el
@@ -5,7 +5,7 @@
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.43 8;; Version: 4.44
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
@@ -90,10 +90,12 @@
90;; 90;;
91;; Recent changes 91;; Recent changes
92;; -------------- 92;; --------------
93;; Version 4.43 93;; Version 4.44
94;; - Big fixes 94;; - Clock table can be done for a limited time interval.
95;; - Obsolete support for the old outline mode has been removed.
96;; - Bug fixes and code cleaning.
95;; 97;;
96;; Version 4.42 98;; Version 4.43
97;; - Bug fixes 99;; - Bug fixes
98;; - `s' key in the agenda saves all org-mode buffers. 100;; - `s' key in the agenda saves all org-mode buffers.
99;; 101;;
@@ -212,16 +214,13 @@
212 214
213;;; Customization variables 215;;; Customization variables
214 216
215(defvar org-version "4.43" 217(defvar org-version "4.44"
216 "The version number of the file org.el.") 218 "The version number of the file org.el.")
217(defun org-version () 219(defun org-version ()
218 (interactive) 220 (interactive)
219 (message "Org-mode version %s" org-version)) 221 (message "Org-mode version %s" org-version))
220 222
221;; The following constant is for compatibility with different versions 223;; Compatibility constants
222;; of outline.el.
223(defconst org-noutline-p (featurep 'noutline)
224 "Are we using the new outline mode?")
225(defconst org-xemacs-p (featurep 'xemacs)) ; not used by org.el itself 224(defconst org-xemacs-p (featurep 'xemacs)) ; not used by org.el itself
226(defconst org-format-transports-properties-p 225(defconst org-format-transports-properties-p
227 (let ((x "a")) 226 (let ((x "a"))
@@ -1132,7 +1131,7 @@ files and the cdr the corresponding command. Possible values for the
1132file identifier are 1131file identifier are
1133 \"ext\" A string identifying an extension 1132 \"ext\" A string identifying an extension
1134 `directory' Matches a directory 1133 `directory' Matches a directory
1135 `remote' Matches a remove file, accessible through tramp or efs. 1134 `remote' Matches a remote file, accessible through tramp or efs.
1136 Remote files most likely should be visited through emacs 1135 Remote files most likely should be visited through emacs
1137 because external applications cannot handle such paths. 1136 because external applications cannot handle such paths.
1138 t Default for all remaining files 1137 t Default for all remaining files
@@ -1831,6 +1830,7 @@ Org-mode files lives."
1831 1830
1832(defcustom org-export-language-setup 1831(defcustom org-export-language-setup
1833 '(("en" "Author" "Date" "Table of Contents") 1832 '(("en" "Author" "Date" "Table of Contents")
1833 ("cs" "Autor" "Datum" "Obsah")
1834 ("da" "Ophavsmand" "Dato" "Indhold") 1834 ("da" "Ophavsmand" "Dato" "Indhold")
1835 ("de" "Autor" "Datum" "Inhaltsverzeichnis") 1835 ("de" "Autor" "Datum" "Inhaltsverzeichnis")
1836 ("es" "Autor" "Fecha" "\xccndice") 1836 ("es" "Autor" "Fecha" "\xccndice")
@@ -2150,6 +2150,16 @@ you can \"misuse\" it to add arbitrary text to the header."
2150 :group 'org-export-html 2150 :group 'org-export-html
2151 :type 'string) 2151 :type 'string)
2152 2152
2153(defcustom org-export-html-title-format "<h1 class=\"title\">%s</h1>\n"
2154 "Format for typesetting the document title in HTML export."
2155 :group 'org-export-html
2156 :type 'string)
2157
2158(defcustom org-export-html-toplevel-hlevel 2
2159 "The <H> level for level 1 headings in HTML export."
2160 :group 'org-export-html
2161 :type 'string)
2162
2153(defcustom org-export-html-link-org-files-as-html t 2163(defcustom org-export-html-link-org-files-as-html t
2154 "Non-nil means, make file links to `file.org' point to `file.html'. 2164 "Non-nil means, make file links to `file.org' point to `file.html'.
2155When org-mode is exporting an org-mode file to HTML, links to 2165When org-mode is exporting an org-mode file to HTML, links to
@@ -2694,6 +2704,10 @@ Also put tags into group 4 if tags are present.")
2694 (remove-text-properties 0 (length s) org-rm-props s) 2704 (remove-text-properties 0 (length s) org-rm-props s)
2695 s) 2705 s)
2696 2706
2707(defsubst org-set-local (var value)
2708 "Make VAR local in current buffer and set it to VALUE."
2709 (set (make-variable-buffer-local var) value))
2710
2697(defsubst org-mode-p () 2711(defsubst org-mode-p ()
2698 "Check if the current buffer is in Org-mode." 2712 "Check if the current buffer is in Org-mode."
2699 (eq major-mode 'org-mode)) 2713 (eq major-mode 'org-mode))
@@ -2703,7 +2717,7 @@ Also put tags into group 4 if tags are present.")
2703 (when (org-mode-p) 2717 (when (org-mode-p)
2704 (let ((re (org-make-options-regexp 2718 (let ((re (org-make-options-regexp
2705 '("CATEGORY" "SEQ_TODO" "PRI_TODO" "TYP_TODO" 2719 '("CATEGORY" "SEQ_TODO" "PRI_TODO" "TYP_TODO"
2706 "STARTUP" "ARCHIVE" "TAGS"))) 2720 "STARTUP" "ARCHIVE" "TAGS" "CALC")))
2707 (splitre "[ \t]+") 2721 (splitre "[ \t]+")
2708 kwds int key value cat arch tags) 2722 kwds int key value cat arch tags)
2709 (save-excursion 2723 (save-excursion
@@ -2755,10 +2769,10 @@ Also put tags into group 4 if tags are present.")
2755 (remove-text-properties 0 (length arch) 2769 (remove-text-properties 0 (length arch)
2756 '(face t fontified t) arch))) 2770 '(face t fontified t) arch)))
2757 ))) 2771 )))
2758 (and cat (set (make-local-variable 'org-category) cat)) 2772 (and cat (org-set-local 'org-category cat))
2759 (and kwds (set (make-local-variable 'org-todo-keywords) kwds)) 2773 (and kwds (org-set-local 'org-todo-keywords kwds))
2760 (and arch (set (make-local-variable 'org-archive-location) arch)) 2774 (and arch (org-set-local 'org-archive-location arch))
2761 (and int (set (make-local-variable 'org-todo-interpretation) int)) 2775 (and int (org-set-local 'org-todo-interpretation int))
2762 (when tags 2776 (when tags
2763 (let (e tgs) 2777 (let (e tgs)
2764 (while (setq e (pop tags)) 2778 (while (setq e (pop tags))
@@ -2770,7 +2784,7 @@ Also put tags into group 4 if tags are present.")
2770 (string-to-char (match-string 2 e))) 2784 (string-to-char (match-string 2 e)))
2771 tgs)) 2785 tgs))
2772 (t (push (list e) tgs)))) 2786 (t (push (list e) tgs))))
2773 (set (make-local-variable 'org-tag-alist) nil) 2787 (org-set-local 'org-tag-alist nil)
2774 (while (setq e (pop tgs)) 2788 (while (setq e (pop tgs))
2775 (or (and (stringp (car e)) 2789 (or (and (stringp (car e))
2776 (assoc (car e) org-tag-alist)) 2790 (assoc (car e) org-tag-alist))
@@ -2928,15 +2942,11 @@ The following commands are available:
2928 ;; Need to do this here because define-derived-mode sets up 2942 ;; Need to do this here because define-derived-mode sets up
2929 ;; the keymap so late. 2943 ;; the keymap so late.
2930 (if (featurep 'xemacs) 2944 (if (featurep 'xemacs)
2931 (if org-noutline-p 2945 (progn
2932 (progn 2946 ;; Assume this is Greg's port, it used easymenu
2933 (easy-menu-remove outline-mode-menu-heading) 2947 (easy-menu-remove outline-mode-menu-heading)
2934 (easy-menu-remove outline-mode-menu-show) 2948 (easy-menu-remove outline-mode-menu-show)
2935 (easy-menu-remove outline-mode-menu-hide)) 2949 (easy-menu-remove outline-mode-menu-hide))
2936 (delete-menu-item '("Headings"))
2937 (delete-menu-item '("Show"))
2938 (delete-menu-item '("Hide"))
2939 (set-menubar-dirty-flag))
2940 (define-key org-mode-map [menu-bar headings] 'undefined) 2950 (define-key org-mode-map [menu-bar headings] 'undefined)
2941 (define-key org-mode-map [menu-bar hide] 'undefined) 2951 (define-key org-mode-map [menu-bar hide] 'undefined)
2942 (define-key org-mode-map [menu-bar show] 'undefined)) 2952 (define-key org-mode-map [menu-bar show] 'undefined))
@@ -2947,7 +2957,7 @@ The following commands are available:
2947 (if org-descriptive-links (org-add-to-invisibility-spec '(org-link))) 2957 (if org-descriptive-links (org-add-to-invisibility-spec '(org-link)))
2948 (org-add-to-invisibility-spec '(org-cwidth)) 2958 (org-add-to-invisibility-spec '(org-cwidth))
2949 (when (featurep 'xemacs) 2959 (when (featurep 'xemacs)
2950 (set (make-local-variable 'line-move-ignore-invisible) t)) 2960 (org-set-local 'line-move-ignore-invisible t))
2951 (setq outline-regexp "\\*+") 2961 (setq outline-regexp "\\*+")
2952 ;;(setq outline-regexp "\\(?:\\*+\\|[ \t]*\\(?:[-+*]\\|[0-9]+[.)]\\) \\)") 2962 ;;(setq outline-regexp "\\(?:\\*+\\|[ \t]*\\(?:[-+*]\\|[0-9]+[.)]\\) \\)")
2953 (setq outline-level 'org-outline-level) 2963 (setq outline-level 'org-outline-level)
@@ -2958,12 +2968,14 @@ The following commands are available:
2958 4 (string-to-vector org-ellipsis)) 2968 4 (string-to-vector org-ellipsis))
2959 (setq buffer-display-table org-display-table)) 2969 (setq buffer-display-table org-display-table))
2960 (org-set-regexps-and-options) 2970 (org-set-regexps-and-options)
2971 ;; Calc embedded
2972 (org-set-local 'calc-embedded-open-mode "# ")
2961 (modify-syntax-entry ?# "<") 2973 (modify-syntax-entry ?# "<")
2962 (if org-startup-truncated (setq truncate-lines t)) 2974 (if org-startup-truncated (setq truncate-lines t))
2963 (set (make-local-variable 'font-lock-unfontify-region-function) 2975 (org-set-local 'font-lock-unfontify-region-function
2964 'org-unfontify-region) 2976 'org-unfontify-region)
2965 ;; Activate before-change-function 2977 ;; Activate before-change-function
2966 (set (make-local-variable 'org-table-may-need-update) t) 2978 (org-set-local 'org-table-may-need-update t)
2967 (org-add-hook 'before-change-functions 'org-before-change-function nil 2979 (org-add-hook 'before-change-functions 'org-before-change-function nil
2968 'local) 2980 'local)
2969 ;; Check for running clock before killing a buffer 2981 ;; Check for running clock before killing a buffer
@@ -3107,7 +3119,7 @@ that will be added to PLIST. Returns the string that was modified."
3107 org-ts-regexp "\\)?") 3119 org-ts-regexp "\\)?")
3108 "Regular expression matching a time stamp or time stamp range.") 3120 "Regular expression matching a time stamp or time stamp range.")
3109 3121
3110(defvar org-§emph-face nil) 3122(defvar org-§emph-face nil)
3111 3123
3112(defun org-do-emphasis-faces (limit) 3124(defun org-do-emphasis-faces (limit)
3113 "Run through the buffer and add overlays to links." 3125 "Run through the buffer and add overlays to links."
@@ -3340,10 +3352,9 @@ between words."
3340 ))) 3352 )))
3341 (setq org-font-lock-extra-keywords (delq nil org-font-lock-extra-keywords)) 3353 (setq org-font-lock-extra-keywords (delq nil org-font-lock-extra-keywords))
3342 ;; Now set the full font-lock-keywords 3354 ;; Now set the full font-lock-keywords
3343 (set (make-local-variable 'org-font-lock-keywords) 3355 (org-set-local 'org-font-lock-keywords org-font-lock-extra-keywords)
3344 org-font-lock-extra-keywords) 3356 (org-set-local 'font-lock-defaults
3345 (set (make-local-variable 'font-lock-defaults) 3357 '(org-font-lock-keywords t nil nil backward-paragraph))
3346 '(org-font-lock-keywords t nil nil backward-paragraph))
3347 (kill-local-variable 'font-lock-keywords) nil)) 3358 (kill-local-variable 'font-lock-keywords) nil))
3348 3359
3349(defvar org-m nil) 3360(defvar org-m nil)
@@ -3812,9 +3823,7 @@ state (TODO by default). Also with prefix arg, force first state."
3812 (org-insert-heading) 3823 (org-insert-heading)
3813 (save-excursion 3824 (save-excursion
3814 (org-back-to-heading) 3825 (org-back-to-heading)
3815 (if org-noutline-p 3826 (outline-previous-heading)
3816 (outline-previous-heading)
3817 (outline-previous-visible-heading t))
3818 (looking-at org-todo-line-regexp)) 3827 (looking-at org-todo-line-regexp))
3819 (if (or arg 3828 (if (or arg
3820 (not (match-beginning 2)) 3829 (not (match-beginning 2))
@@ -4703,7 +4712,7 @@ the children that do not contain any open TODO items."
4703 (pc '(:org-comment t)) 4712 (pc '(:org-comment t))
4704 (pall '(:org-archived t :org-comment t)) 4713 (pall '(:org-archived t :org-comment t))
4705 (rea (concat ":" org-archive-tag ":")) 4714 (rea (concat ":" org-archive-tag ":"))
4706 bmp file re) 4715 bmp file re)
4707 (save-excursion 4716 (save-excursion
4708 (while (setq file (pop files)) 4717 (while (setq file (pop files))
4709 (org-check-agenda-file file) 4718 (org-check-agenda-file file)
@@ -4775,7 +4784,7 @@ If not found, stay at current position and return nil."
4775 pos)) 4784 pos))
4776 4785
4777(defconst org-dblock-start-re 4786(defconst org-dblock-start-re
4778 "^#\\+BEGIN:[ \t]+\\(\\S-+\\)[ \t]+\\(.*\\)" 4787 "^#\\+BEGIN:[ \t]+\\(\\S-+\\)\\([ \t]+\\(.*\\)\\)?"
4779 "Matches the startline of a dynamic block, with parameters.") 4788 "Matches the startline of a dynamic block, with parameters.")
4780 4789
4781(defconst org-dblock-end-re "^#\\+END\\([: \t\r\n]\\|$\\)" 4790(defconst org-dblock-end-re "^#\\+END\\([: \t\r\n]\\|$\\)"
@@ -4803,7 +4812,7 @@ the property list including an extra property :name with the block name."
4803 (let* ((begdel (1+ (match-end 0))) 4812 (let* ((begdel (1+ (match-end 0)))
4804 (name (match-string 1)) 4813 (name (match-string 1))
4805 (params (append (list :name name) 4814 (params (append (list :name name)
4806 (read (concat "(" (match-string 2) ")"))))) 4815 (read (concat "(" (match-string 3) ")")))))
4807 (unless (re-search-forward org-dblock-end-re nil t) 4816 (unless (re-search-forward org-dblock-end-re nil t)
4808 (error "Dynamic block not terminated")) 4817 (error "Dynamic block not terminated"))
4809 (delete-region begdel (match-beginning 0)) 4818 (delete-region begdel (match-beginning 0))
@@ -5200,7 +5209,6 @@ If CALLBACK is non-nil, it is a function which is called to confirm
5200that the match should indeed be shown." 5209that the match should indeed be shown."
5201 (interactive "sRegexp: ") 5210 (interactive "sRegexp: ")
5202 (org-remove-occur-highlights nil nil t) 5211 (org-remove-occur-highlights nil nil t)
5203 (setq regexp (org-check-occur-regexp regexp))
5204 (let ((cnt 0)) 5212 (let ((cnt 0))
5205 (save-excursion 5213 (save-excursion
5206 (goto-char (point-min)) 5214 (goto-char (point-min))
@@ -5625,56 +5633,58 @@ next column.
5625For time difference computation, a year is assumed to be exactly 365 5633For time difference computation, a year is assumed to be exactly 365
5626days in order to avoid rounding problems." 5634days in order to avoid rounding problems."
5627 (interactive "P") 5635 (interactive "P")
5628 (save-excursion 5636 (or
5629 (unless (org-at-date-range-p) 5637 (org-clock-update-time-maybe)
5630 (goto-char (point-at-bol)) 5638 (save-excursion
5631 (re-search-forward org-tr-regexp (point-at-eol) t)) 5639 (unless (org-at-date-range-p)
5632 (if (not (org-at-date-range-p)) 5640 (goto-char (point-at-bol))
5633 (error "Not at a time-stamp range, and none found in current line"))) 5641 (re-search-forward org-tr-regexp (point-at-eol) t))
5634 (let* ((ts1 (match-string 1)) 5642 (if (not (org-at-date-range-p))
5635 (ts2 (match-string 2)) 5643 (error "Not at a time-stamp range, and none found in current line")))
5636 (havetime (or (> (length ts1) 15) (> (length ts2) 15))) 5644 (let* ((ts1 (match-string 1))
5637 (match-end (match-end 0)) 5645 (ts2 (match-string 2))
5638 (time1 (org-time-string-to-time ts1)) 5646 (havetime (or (> (length ts1) 15) (> (length ts2) 15)))
5639 (time2 (org-time-string-to-time ts2)) 5647 (match-end (match-end 0))
5640 (t1 (time-to-seconds time1)) 5648 (time1 (org-time-string-to-time ts1))
5641 (t2 (time-to-seconds time2)) 5649 (time2 (org-time-string-to-time ts2))
5642 (diff (abs (- t2 t1))) 5650 (t1 (time-to-seconds time1))
5643 (negative (< (- t2 t1) 0)) 5651 (t2 (time-to-seconds time2))
5644 ;; (ys (floor (* 365 24 60 60))) 5652 (diff (abs (- t2 t1)))
5645 (ds (* 24 60 60)) 5653 (negative (< (- t2 t1) 0))
5646 (hs (* 60 60)) 5654 ;; (ys (floor (* 365 24 60 60)))
5647 (fy "%dy %dd %02d:%02d") 5655 (ds (* 24 60 60))
5648 (fy1 "%dy %dd") 5656 (hs (* 60 60))
5649 (fd "%dd %02d:%02d") 5657 (fy "%dy %dd %02d:%02d")
5650 (fd1 "%dd") 5658 (fy1 "%dy %dd")
5651 (fh "%02d:%02d") 5659 (fd "%dd %02d:%02d")
5652 y d h m align) 5660 (fd1 "%dd")
5653 (if havetime 5661 (fh "%02d:%02d")
5654 (setq ; y (floor (/ diff ys)) diff (mod diff ys) 5662 y d h m align)
5655 y 0 5663 (if havetime
5656 d (floor (/ diff ds)) diff (mod diff ds) 5664 (setq ; y (floor (/ diff ys)) diff (mod diff ys)
5657 h (floor (/ diff hs)) diff (mod diff hs) 5665 y 0
5658 m (floor (/ diff 60))) 5666 d (floor (/ diff ds)) diff (mod diff ds)
5659 (setq ; y (floor (/ diff ys)) diff (mod diff ys) 5667 h (floor (/ diff hs)) diff (mod diff hs)
5660 y 0 5668 m (floor (/ diff 60)))
5661 d (floor (+ (/ diff ds) 0.5)) 5669 (setq ; y (floor (/ diff ys)) diff (mod diff ys)
5662 h 0 m 0)) 5670 y 0
5663 (if (not to-buffer) 5671 d (floor (+ (/ diff ds) 0.5))
5664 (message (org-make-tdiff-string y d h m)) 5672 h 0 m 0))
5665 (when (org-at-table-p) 5673 (if (not to-buffer)
5666 (goto-char match-end) 5674 (message (org-make-tdiff-string y d h m))
5667 (setq align t) 5675 (when (org-at-table-p)
5668 (and (looking-at " *|") (goto-char (match-end 0)))) 5676 (goto-char match-end)
5669 (if (looking-at 5677 (setq align t)
5670 "\\( *-? *[0-9]+y\\)?\\( *[0-9]+d\\)? *[0-9][0-9]:[0-9][0-9]") 5678 (and (looking-at " *|") (goto-char (match-end 0))))
5671 (replace-match "")) 5679 (if (looking-at
5672 (if negative (insert " -")) 5680 "\\( *-? *[0-9]+y\\)?\\( *[0-9]+d\\)? *[0-9][0-9]:[0-9][0-9]")
5673 (if (> y 0) (insert " " (format (if havetime fy fy1) y d h m)) 5681 (replace-match ""))
5674 (if (> d 0) (insert " " (format (if havetime fd fd1) d h m)) 5682 (if negative (insert " -"))
5675 (insert " " (format fh h m)))) 5683 (if (> y 0) (insert " " (format (if havetime fy fy1) y d h m))
5676 (if align (org-table-align)) 5684 (if (> d 0) (insert " " (format (if havetime fd fd1) d h m))
5677 (message "Time difference inserted")))) 5685 (insert " " (format fh h m))))
5686 (if align (org-table-align))
5687 (message "Time difference inserted")))))
5678 5688
5679(defun org-make-tdiff-string (y d h m) 5689(defun org-make-tdiff-string (y d h m)
5680 (let ((fmt "") 5690 (let ((fmt "")
@@ -5817,6 +5827,7 @@ in the timestamp determines what will be changed."
5817 (setcar (nthcdr 2 time0) (or (nth 1 time0) 0)) 5827 (setcar (nthcdr 2 time0) (or (nth 1 time0) 0))
5818 (setq time (apply 'encode-time time0)))) 5828 (setq time (apply 'encode-time time0))))
5819 (insert (setq org-last-changed-timestamp (format-time-string fmt time))) 5829 (insert (setq org-last-changed-timestamp (format-time-string fmt time)))
5830 (org-clock-update-time-maybe)
5820 (goto-char pos) 5831 (goto-char pos)
5821 ;; Try to recenter the calendar window, if any 5832 ;; Try to recenter the calendar window, if any
5822 (if (and org-calendar-follow-timestamp-change 5833 (if (and org-calendar-follow-timestamp-change
@@ -5937,18 +5948,19 @@ If there is no running clock, throw an error, unless FAIL-QUIETLY is set."
5937 "Holds the file total time in minutes, after a call to `org-clock-sum'.") 5948 "Holds the file total time in minutes, after a call to `org-clock-sum'.")
5938 (make-variable-buffer-local 'org-clock-file-total-minutes) 5949 (make-variable-buffer-local 'org-clock-file-total-minutes)
5939 5950
5940(defun org-clock-sum () 5951(defun org-clock-sum (&optional tstart tend)
5941 "Sum the times for each subtree. 5952 "Sum the times for each subtree.
5942Puts the resulting times in minutes as a text property on each headline." 5953Puts the resulting times in minutes as a text property on each headline."
5943 (interactive) 5954 (interactive)
5944 (let* ((bmp (buffer-modified-p)) 5955 (let* ((bmp (buffer-modified-p))
5945 (re (concat "^\\(\\*+\\)[ \t]\\|^[ \t]*" 5956 (re (concat "^\\(\\*+\\)[ \t]\\|^[ \t]*"
5946 org-clock-string 5957 org-clock-string
5947 ".*=>[ \t]*\\([0-9]+\\):\\([0-9]+\\)[ \t]*$")) 5958 "[ \t]*\\(\\[.*?\\]\\)-+\\(\\[.*?\\]\\)"))
5948 (lmax 30) 5959 (lmax 30)
5949 (ltimes (make-vector lmax 0)) 5960 (ltimes (make-vector lmax 0))
5950 (t1 0) 5961 (t1 0)
5951 (level 0) 5962 (level 0)
5963 ts te dt
5952 time) 5964 time)
5953 (remove-text-properties (point-min) (point-max) '(:org-clock-minutes t)) 5965 (remove-text-properties (point-min) (point-max) '(:org-clock-minutes t))
5954 (save-excursion 5966 (save-excursion
@@ -5956,8 +5968,16 @@ Puts the resulting times in minutes as a text property on each headline."
5956 (while (re-search-backward re nil t) 5968 (while (re-search-backward re nil t)
5957 (if (match-end 2) 5969 (if (match-end 2)
5958 ;; A time 5970 ;; A time
5959 (setq t1 (+ t1 (* 60 (string-to-number (match-string 2))) 5971 (setq ts (match-string 2)
5960 (string-to-number (match-string 3)))) 5972 te (match-string 3)
5973 ts (time-to-seconds
5974 (apply 'encode-time (org-parse-time-string ts)))
5975 te (time-to-seconds
5976 (apply 'encode-time (org-parse-time-string te)))
5977 ts (if tstart (max ts tstart) ts)
5978 te (if tend (min te tend) te)
5979 dt (- te ts)
5980 t1 (if (> dt 0) (+ t1 (floor (/ dt 60))) t1))
5961 ;; A headline 5981 ;; A headline
5962 (setq level (- (match-end 1) (match-beginning 1))) 5982 (setq level (- (match-end 1) (match-beginning 1)))
5963 (when (or (> t1 0) (> (aref ltimes level) 0)) 5983 (when (or (> t1 0) (> (aref ltimes level) 0))
@@ -6069,26 +6089,112 @@ The BEGIN line can contain parameters. Allowed are:
6069 (interactive) 6089 (interactive)
6070 (org-remove-clock-overlays) 6090 (org-remove-clock-overlays)
6071 (unless (org-find-dblock "clocktable") 6091 (unless (org-find-dblock "clocktable")
6072 (org-create-dblock (list :name "clocktable" 6092 (org-create-dblock (list :name "clocktable"
6073 :maxlevel 2 :emphasize nil))) 6093 :maxlevel 2 :emphasize nil)))
6074 (org-update-dblock)) 6094 (org-update-dblock))
6075 6095
6096(defun org-clock-update-time-maybe ()
6097 "If this is a CLOCK line, update it and return t.
6098Otherwise, return nil."
6099 (interactive)
6100 (save-excursion
6101 (beginning-of-line 1)
6102 (skip-chars-forward " \t")
6103 (when (looking-at org-clock-string)
6104 (let ((re (concat "[ \t]*" org-clock-string
6105 " *[[<]\\([^]>]+\\)[]>]-+[[<]\\([^]>]+\\)[]>]"
6106 "\\([ \t]*=>.*\\)?"))
6107 ts te h m s)
6108 (if (not (looking-at re))
6109 nil
6110 (and (match-end 3) (delete-region (match-beginning 3) (match-end 3)))
6111 (end-of-line 1)
6112 (setq ts (match-string 1)
6113 te (match-string 2))
6114 (setq s (- (time-to-seconds
6115 (apply 'encode-time (org-parse-time-string te)))
6116 (time-to-seconds
6117 (apply 'encode-time (org-parse-time-string ts))))
6118 h (floor (/ s 3600))
6119 s (- s (* 3600 h))
6120 m (floor (/ s 60))
6121 s (- s (* 60 s)))
6122 (insert " => " (format "%2d:%02d" h m))
6123 t)))))
6124
6125(defun org-clock-special-range (key &optional time as-strings)
6126 "Return two times bordering a special time range.
6127Key is a symbol specifying the range and can be one of `today', `yesterday',
6128`thisweek', `lastweek', `thismonth', `lastmonth', `thisyear', `lastyear'.
6129A week starts Monday 0:00 and ends Sunday 24:00.
6130The range is determined relative to TIME. TIME defaults to the current time.
6131The return value is a cons cell with two internal times like the ones
6132returned by `current time' or `encode-time'. if AS-STRINGS is non-nil,
6133the returned times will be formatted strings."
6134 (let* ((tm (decode-time (or time (current-time))))
6135 (s 0) (m (nth 1 tm)) (h (nth 2 tm))
6136 (d (nth 3 tm)) (month (nth 4 tm)) (y (nth 5 tm))
6137 (dow (nth 6 tm))
6138 s1 m1 h1 d1 month1 y1 diff ts te fm)
6139 (cond
6140 ((eq key 'today)
6141 (setq h 0 m 0 h1 24 m1 0))
6142 ((eq key 'yesterday)
6143 (setq d (1- d) h 0 m 0 h1 24 m1 0))
6144 ((eq key 'thisweek)
6145 (setq diff (if (= dow 0) 6 (1- dow))
6146 m 0 h 0 d (- d diff) d1 (+ 7 d)))
6147 ((eq key 'lastweek)
6148 (setq diff (+ 7 (if (= dow 0) 6 (1- dow)))
6149 m 0 h 0 d (- d diff) d1 (+ 7 d)))
6150 ((eq key 'thismonth)
6151 (setq d 1 h 0 m 0 d1 1 month1 (1+ month) h1 0 m1 0))
6152 ((eq key 'lastmonth)
6153 (setq d 1 h 0 m 0 d1 1 month (1- month) month1 (1+ month) h1 0 m1 0))
6154 ((eq key 'thisyear)
6155 (setq m 0 h 0 d 1 month 1 y1 (1+ y)))
6156 ((eq key 'lastyear)
6157 (setq m 0 h 0 d 1 month 1 y (1- y) y1 (1+ y)))
6158 (t (error "No such time block %s" key)))
6159 (setq ts (encode-time s m h d month y)
6160 te (encode-time (or s1 s) (or m1 m) (or h1 h)
6161 (or d1 d) (or month1 month) (or y1 y)))
6162 (setq fm (cdr org-time-stamp-formats))
6163 (if as-strings
6164 (cons (format-time-string fm ts) (format-time-string fm te))
6165 (cons ts te))))
6166
6076(defun org-dblock-write:clocktable (params) 6167(defun org-dblock-write:clocktable (params)
6077 "Write the standard clocktable." 6168 "Write the standard clocktable."
6078 (let ((hlchars '((1 . "*") (2 . ?/))) 6169 (let ((hlchars '((1 . "*") (2 . ?/)))
6079 (emph nil) 6170 (emph nil)
6080 (ins (make-marker)) 6171 (ins (make-marker))
6081 ipos time h m p level hlc hdl maxlevel) 6172 ipos time h m p level hlc hdl maxlevel
6173 ts te cc block)
6082 (setq maxlevel (or (plist-get params :maxlevel) 3) 6174 (setq maxlevel (or (plist-get params :maxlevel) 3)
6083 emph (plist-get params :emphasize)) 6175 emph (plist-get params :emphasize)
6176 ts (plist-get params :tstart)
6177 te (plist-get params :tend)
6178 block (plist-get params :block))
6179 (when block
6180 (setq cc (org-clock-special-range block nil t)
6181 ts (car cc) te (cdr cc)))
6182 (if ts (setq ts (time-to-seconds
6183 (apply 'encode-time (org-parse-time-string ts)))))
6184 (if te (setq te (time-to-seconds
6185 (apply 'encode-time (org-parse-time-string te)))))
6084 (move-marker ins (point)) 6186 (move-marker ins (point))
6085 (setq ipos (point)) 6187 (setq ipos (point))
6086 (insert-before-markers "Clock summary at [" 6188 (insert-before-markers "Clock summary at ["
6087 (substring 6189 (substring
6088 (format-time-string (cdr org-time-stamp-formats)) 6190 (format-time-string (cdr org-time-stamp-formats))
6089 1 -1) 6191 1 -1)
6090 "]\n|L|Headline|Time|\n") 6192 "]."
6091 (org-clock-sum) 6193 (if block
6194 (format " Considered range is /%s/." block)
6195 "")
6196 "\n\n|L|Headline|Time|\n")
6197 (org-clock-sum ts te)
6092 (setq h (/ org-clock-file-total-minutes 60) 6198 (setq h (/ org-clock-file-total-minutes 60)
6093 m (- org-clock-file-total-minutes (* 60 h))) 6199 m (- org-clock-file-total-minutes (* 60 h)))
6094 (insert-before-markers "|-\n|0|" "*Total file time*| " 6200 (insert-before-markers "|-\n|0|" "*Total file time*| "
@@ -6475,7 +6581,7 @@ the buffer and restores the previous window configuration."
6475 (if (stringp org-agenda-files) 6581 (if (stringp org-agenda-files)
6476 (let ((cw (current-window-configuration))) 6582 (let ((cw (current-window-configuration)))
6477 (find-file org-agenda-files) 6583 (find-file org-agenda-files)
6478 (set (make-local-variable 'org-window-configuration) cw) 6584 (org-set-local 'org-window-configuration cw)
6479 (org-add-hook 'after-save-hook 6585 (org-add-hook 'after-save-hook
6480 (lambda () 6586 (lambda ()
6481 (set-window-configuration 6587 (set-window-configuration
@@ -6603,7 +6709,7 @@ dates."
6603 (setq buffer-read-only nil) 6709 (setq buffer-read-only nil)
6604 (erase-buffer) 6710 (erase-buffer)
6605 (org-agenda-mode) (setq buffer-read-only nil) 6711 (org-agenda-mode) (setq buffer-read-only nil)
6606 (set (make-local-variable 'org-agenda-type) 'timeline) 6712 (org-set-local 'org-agenda-type 'timeline)
6607 (if doclosed (push :closed args)) 6713 (if doclosed (push :closed args))
6608 (push :timestamp args) 6714 (push :timestamp args)
6609 (if dotodo (push :todo args)) 6715 (if dotodo (push :todo args))
@@ -6701,9 +6807,9 @@ NDAYS defaults to `org-agenda-ndays'."
6701 (setq buffer-read-only nil) 6807 (setq buffer-read-only nil)
6702 (erase-buffer) 6808 (erase-buffer)
6703 (org-agenda-mode) (setq buffer-read-only nil) 6809 (org-agenda-mode) (setq buffer-read-only nil)
6704 (set (make-local-variable 'org-agenda-type) 'agenda) 6810 (org-set-local 'org-agenda-type 'agenda)
6705 (set (make-local-variable 'starting-day) (car day-numbers)) 6811 (org-set-local 'starting-day (car day-numbers))
6706 (set (make-local-variable 'include-all-loc) include-all) 6812 (org-set-local 'include-all-loc include-all)
6707 (when (and (or include-all org-agenda-include-all-todo) 6813 (when (and (or include-all org-agenda-include-all-todo)
6708 (member today day-numbers)) 6814 (member today day-numbers))
6709 (setq files thefiles 6815 (setq files thefiles
@@ -6812,11 +6918,11 @@ for a keyword. A numeric prefix directly selects the Nth keyword in
6812 (setq buffer-read-only nil) 6918 (setq buffer-read-only nil)
6813 (erase-buffer) 6919 (erase-buffer)
6814 (org-agenda-mode) (setq buffer-read-only nil) 6920 (org-agenda-mode) (setq buffer-read-only nil)
6815 (set (make-local-variable 'org-agenda-type) 'todo) 6921 (org-set-local 'org-agenda-type 'todo)
6816 (set (make-local-variable 'last-arg) arg) 6922 (org-set-local 'last-arg arg)
6817 (set (make-local-variable 'org-todo-keywords) kwds) 6923 (org-set-local 'org-todo-keywords kwds)
6818 (set (make-local-variable 'org-agenda-redo-command) 6924 (org-set-local 'org-agenda-redo-command
6819 '(org-todo-list (or current-prefix-arg last-arg) t)) 6925 '(org-todo-list (or current-prefix-arg last-arg) t))
6820 (setq files (org-agenda-files) 6926 (setq files (org-agenda-files)
6821 rtnall nil) 6927 rtnall nil)
6822 (org-prepare-agenda-buffers files) 6928 (org-prepare-agenda-buffers files)
@@ -7704,11 +7810,12 @@ the documentation of `org-diary'."
7704 (abbreviate-file-name buffer-file-name)))) 7810 (abbreviate-file-name buffer-file-name))))
7705 (regexp org-tr-regexp) 7811 (regexp org-tr-regexp)
7706 (d0 (calendar-absolute-from-gregorian date)) 7812 (d0 (calendar-absolute-from-gregorian date))
7707 marker hdmarker ee txt d1 d2 s1 s2 timestr category tags) 7813 marker hdmarker ee txt d1 d2 s1 s2 timestr category tags pos)
7708 (goto-char (point-min)) 7814 (goto-char (point-min))
7709 (while (re-search-forward regexp nil t) 7815 (while (re-search-forward regexp nil t)
7710 (catch :skip 7816 (catch :skip
7711 (org-agenda-skip) 7817 (org-agenda-skip)
7818 (setq pos (point))
7712 (setq timestr (match-string 0) 7819 (setq timestr (match-string 0)
7713 s1 (match-string 1) 7820 s1 (match-string 1)
7714 s2 (match-string 2) 7821 s2 (match-string 2)
@@ -7736,7 +7843,8 @@ the documentation of `org-diary'."
7736 'org-marker marker 'org-hd-marker hdmarker 7843 'org-marker marker 'org-hd-marker hdmarker
7737 'priority (org-get-priority txt) 'category category) 7844 'priority (org-get-priority txt) 'category category)
7738 (push txt ee))) 7845 (push txt ee)))
7739 (outline-next-heading))) 7846 (goto-char pos)))
7847; (outline-next-heading))) ;FIXME: correct to be removed??????
7740 ;; Sort the entries by expiration date. 7848 ;; Sort the entries by expiration date.
7741 (nreverse ee))) 7849 (nreverse ee)))
7742 7850
@@ -7757,7 +7865,7 @@ groups carry important information:
7757 7865
7758(defconst org-stamp-time-of-day-regexp 7866(defconst org-stamp-time-of-day-regexp
7759 (concat 7867 (concat
7760 "<\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} +[a-zA-Z]+ +\\)" 7868 "<\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\} +\\sw+ +\\)"
7761 "\\([012][0-9]:[0-5][0-9]\\)>" 7869 "\\([012][0-9]:[0-5][0-9]\\)>"
7762 "\\(--?" 7870 "\\(--?"
7763 "<\\1\\([012][0-9]:[0-5][0-9]\\)>\\)?") 7871 "<\\1\\([012][0-9]:[0-5][0-9]\\)>\\)?")
@@ -8620,10 +8728,10 @@ The prefix arg TODO-ONLY limits the search to TODO entries."
8620 (setq buffer-read-only nil) 8728 (setq buffer-read-only nil)
8621 (erase-buffer) 8729 (erase-buffer)
8622 (org-agenda-mode) (setq buffer-read-only nil) 8730 (org-agenda-mode) (setq buffer-read-only nil)
8623 (set (make-local-variable 'org-agenda-type) 'tags) 8731 (org-set-local 'org-agenda-type 'tags)
8624 (set (make-local-variable 'org-agenda-redo-command) 8732 (org-set-local 'org-agenda-redo-command
8625 (list 'org-tags-view (list 'quote todo-only) 8733 (list 'org-tags-view (list 'quote todo-only)
8626 (list 'if 'current-prefix-arg nil match) t)) 8734 (list 'if 'current-prefix-arg nil match) t))
8627 (setq files (org-agenda-files) 8735 (setq files (org-agenda-files)
8628 rtnall nil) 8736 rtnall nil)
8629 (org-prepare-agenda-buffers files) 8737 (org-prepare-agenda-buffers files)
@@ -9359,6 +9467,7 @@ onto the ring."
9359 "Follow a Gnus link to GROUP and ARTICLE." 9467 "Follow a Gnus link to GROUP and ARTICLE."
9360 (require 'gnus) 9468 (require 'gnus)
9361 (funcall (cdr (assq 'gnus org-link-frame-setup))) 9469 (funcall (cdr (assq 'gnus org-link-frame-setup)))
9470 (if gnus-other-frame-object (select-frame gnus-other-frame-object))
9362 (if group (gnus-fetch-group group)) 9471 (if group (gnus-fetch-group group))
9363 (if article 9472 (if article
9364 (or (gnus-summary-goto-article article nil 'force) 9473 (or (gnus-summary-goto-article article nil 'force)
@@ -10234,13 +10343,13 @@ to be run from that hook to fucntion properly."
10234 (org-startup-with-deadline-check nil)) 10343 (org-startup-with-deadline-check nil))
10235 (org-mode)) 10344 (org-mode))
10236 (if (and file (string-match "\\S-" file) (not (file-directory-p file))) 10345 (if (and file (string-match "\\S-" file) (not (file-directory-p file)))
10237 (set (make-local-variable 'org-default-notes-file) file)) 10346 (org-set-local 'org-default-notes-file file))
10238 (goto-char (point-min)) 10347 (goto-char (point-min))
10239 (if (re-search-forward "%\\?" nil t) (replace-match ""))) 10348 (if (re-search-forward "%\\?" nil t) (replace-match "")))
10240 (let ((org-startup-folded nil) 10349 (let ((org-startup-folded nil)
10241 (org-startup-with-deadline-check nil)) 10350 (org-startup-with-deadline-check nil))
10242 (org-mode))) 10351 (org-mode)))
10243 (set (make-local-variable 'org-finish-function) 'remember-buffer)) 10352 (org-set-local 'org-finish-function 'remember-buffer))
10244 10353
10245;;;###autoload 10354;;;###autoload
10246(defun org-remember-handler () 10355(defun org-remember-handler ()
@@ -11492,10 +11601,10 @@ it can be edited in place."
11492 '(invisible t org-cwidth t display t 11601 '(invisible t org-cwidth t display t
11493 intangible t)) 11602 intangible t))
11494 (goto-char p) 11603 (goto-char p)
11495 (set (make-local-variable 'org-finish-function) 11604 (org-set-local 'org-finish-function
11496 'org-table-finish-edit-field) 11605 'org-table-finish-edit-field)
11497 (set (make-local-variable 'org-window-configuration) cw) 11606 (org-set-local 'org-window-configuration cw)
11498 (set (make-local-variable 'org-field-marker) pos) 11607 (org-set-local 'org-field-marker pos)
11499 (message "Edit and finish with C-c C-c")))) 11608 (message "Edit and finish with C-c C-c"))))
11500 11609
11501(defun org-table-finish-edit-field () 11610(defun org-table-finish-edit-field ()
@@ -12098,10 +12207,11 @@ not overwrite the stored one."
12098 (setq formula (car tmp) 12207 (setq formula (car tmp)
12099 fmt (concat (cdr (assoc "%" org-table-local-parameters)) 12208 fmt (concat (cdr (assoc "%" org-table-local-parameters))
12100 (nth 1 tmp))) 12209 (nth 1 tmp)))
12101 (while (string-match "[pnfse]\\(-?[0-9]+\\)" fmt) 12210 (while (string-match "\\([pnfse]\\)\\(-?[0-9]+\\)" fmt)
12102 (setq c (string-to-char (match-string 1 fmt)) 12211 (setq c (string-to-char (match-string 1 fmt))
12103 n (string-to-number (or (match-string 1 fmt) ""))) 12212 n (string-to-number (match-string 2 fmt)))
12104 (if (= c ?p) (setq modes (org-set-calc-mode 'calc-internal-prec n)) 12213 (if (= c ?p)
12214 (setq modes (org-set-calc-mode 'calc-internal-prec n))
12105 (setq modes (org-set-calc-mode 12215 (setq modes (org-set-calc-mode
12106 'calc-float-format 12216 'calc-float-format
12107 (list (cdr (assoc c '((?n . float) (?f . fix) 12217 (list (cdr (assoc c '((?n . float) (?f . fix)
@@ -12314,8 +12424,8 @@ Parameters get priority."
12314 (switch-to-buffer-other-window "*Edit Formulas*") 12424 (switch-to-buffer-other-window "*Edit Formulas*")
12315 (erase-buffer) 12425 (erase-buffer)
12316 (fundamental-mode) 12426 (fundamental-mode)
12317 (set (make-local-variable 'org-pos) pos) 12427 (org-set-local 'org-pos pos)
12318 (set (make-local-variable 'org-window-configuration) wc) 12428 (org-set-local 'org-window-configuration wc)
12319 (use-local-map org-edit-formulas-map) 12429 (use-local-map org-edit-formulas-map)
12320 (setq s "# Edit formulas and finish with `C-c C-c'. 12430 (setq s "# Edit formulas and finish with `C-c C-c'.
12321# Use `C-u C-c C-c' to also appy them immediately to the entire table. 12431# Use `C-u C-c C-c' to also appy them immediately to the entire table.
@@ -12481,15 +12591,15 @@ table editor in arbitrary modes.")
12481 (let ((c (assq 'orgtbl-mode minor-mode-map-alist))) 12591 (let ((c (assq 'orgtbl-mode minor-mode-map-alist)))
12482 (and c (setq minor-mode-map-alist 12592 (and c (setq minor-mode-map-alist
12483 (cons c (delq c minor-mode-map-alist))))) 12593 (cons c (delq c minor-mode-map-alist)))))
12484 (set (make-local-variable (quote org-table-may-need-update)) t) 12594 (org-set-local (quote org-table-may-need-update) t)
12485 (org-add-hook 'before-change-functions 'org-before-change-function 12595 (org-add-hook 'before-change-functions 'org-before-change-function
12486 nil 'local) 12596 nil 'local)
12487 (set (make-local-variable 'org-old-auto-fill-inhibit-regexp) 12597 (org-set-local 'org-old-auto-fill-inhibit-regexp
12488 auto-fill-inhibit-regexp) 12598 auto-fill-inhibit-regexp)
12489 (set (make-local-variable 'auto-fill-inhibit-regexp) 12599 (org-set-local 'auto-fill-inhibit-regexp
12490 (if auto-fill-inhibit-regexp 12600 (if auto-fill-inhibit-regexp
12491 (concat "\\([ \t]*|\\|" auto-fill-inhibit-regexp) 12601 (concat "\\([ \t]*|\\|" auto-fill-inhibit-regexp)
12492 "[ \t]*|")) 12602 "[ \t]*|"))
12493 (org-add-to-invisibility-spec '(org-cwidth)) 12603 (org-add-to-invisibility-spec '(org-cwidth))
12494 (easy-menu-add orgtbl-mode-menu) 12604 (easy-menu-add orgtbl-mode-menu)
12495 (run-hooks 'orgtbl-mode-hook)) 12605 (run-hooks 'orgtbl-mode-hook))
@@ -13388,7 +13498,7 @@ underlined headlines. The default is 3."
13388 (set (make-local-variable (cdr x)) 13498 (set (make-local-variable (cdr x))
13389 (plist-get opt-plist (car x)))) 13499 (plist-get opt-plist (car x))))
13390 org-export-plist-vars) 13500 org-export-plist-vars)
13391 (set (make-local-variable 'org-odd-levels-only) odd) 13501 (org-set-local 'org-odd-levels-only odd)
13392 (setq umax (if arg (prefix-numeric-value arg) 13502 (setq umax (if arg (prefix-numeric-value arg)
13393 org-export-headline-levels)) 13503 org-export-headline-levels))
13394 13504
@@ -13594,22 +13704,15 @@ command."
13594 (goto-char (point-min))))) 13704 (goto-char (point-min)))))
13595 13705
13596(defun org-find-visible () 13706(defun org-find-visible ()
13597 (if (featurep 'noutline) 13707 (let ((s (point)))
13598 (let ((s (point))) 13708 (while (and (not (= (point-max) (setq s (next-overlay-change s))))
13599 (while (and (not (= (point-max) (setq s (next-overlay-change s)))) 13709 (get-char-property s 'invisible)))
13600 (get-char-property s 'invisible))) 13710 s))
13601 s)
13602 (skip-chars-forward "^\n")
13603 (point)))
13604(defun org-find-invisible () 13711(defun org-find-invisible ()
13605 (if (featurep 'noutline) 13712 (let ((s (point)))
13606 (let ((s (point))) 13713 (while (and (not (= (point-max) (setq s (next-overlay-change s))))
13607 (while (and (not (= (point-max) (setq s (next-overlay-change s)))) 13714 (not (get-char-property s 'invisible))))
13608 (not (get-char-property s 'invisible)))) 13715 s))
13609 s)
13610 (skip-chars-forward "^\r")
13611 (point)))
13612
13613 13716
13614;; HTML 13717;; HTML
13615 13718
@@ -13859,14 +13962,16 @@ lang=\"%s\" xml:lang=\"%s\">
13859 (insert (or (plist-get opt-plist :preamble) "")) 13962 (insert (or (plist-get opt-plist :preamble) ""))
13860 13963
13861 (when (plist-get opt-plist :auto-preamble) 13964 (when (plist-get opt-plist :auto-preamble)
13862 (if title (insert (concat "<h1 class=\"title\">" 13965 (if title (insert (format org-export-html-title-format
13863 (org-html-expand title) "</h1>\n"))) 13966 (org-html-expand title))))
13864
13865 (if text (insert "<p>\n" (org-html-expand text) "</p>"))) 13967 (if text (insert "<p>\n" (org-html-expand text) "</p>")))
13866 13968
13867 (if org-export-with-toc 13969 (if org-export-with-toc
13868 (progn 13970 (progn
13869 (insert (format "<h2>%s</h2>\n" (nth 3 lang-words))) 13971 (insert (format "<h%d>%s</h%d>\n"
13972 org-export-html-toplevel-hlevel
13973 (nth 3 lang-words)
13974 org-export-html-toplevel-hlevel))
13870 (insert "<ul>\n<li>") 13975 (insert "<ul>\n<li>")
13871 (setq lines 13976 (setq lines
13872 (mapcar '(lambda (line) 13977 (mapcar '(lambda (line)
@@ -14553,7 +14658,7 @@ When TITLE is nil, just close all open levels."
14553 (insert "<ul>\n<li>" title "<br/>\n"))) 14658 (insert "<ul>\n<li>" title "<br/>\n")))
14554 (if org-export-with-section-numbers 14659 (if org-export-with-section-numbers
14555 (setq title (concat (org-section-number level) " " title))) 14660 (setq title (concat (org-section-number level) " " title)))
14556 (setq level (+ level 1)) 14661 (setq level (+ level org-export-html-toplevel-hlevel -1))
14557 (if with-toc 14662 (if with-toc
14558 (insert (format "\n<h%d><a name=\"sec-%d\">%s</a></h%d>\n" 14663 (insert (format "\n<h%d><a name=\"sec-%d\">%s</a></h%d>\n"
14559 level head-count title level)) 14664 level head-count title level))
@@ -15763,6 +15868,10 @@ See the individual commands for more information."
15763 "--" 15868 "--"
15764 ("TODO Lists" 15869 ("TODO Lists"
15765 ["TODO/DONE/-" org-todo t] 15870 ["TODO/DONE/-" org-todo t]
15871 ("Select keyword"
15872 ["Next keyword" org-shiftright (org-on-heading-p)]
15873 ["Previous keyword" org-shiftleft (org-on-heading-p)]
15874 ["Complete Keyword" org-complete (assq :todo-keyword (org-context))])
15766 ["Show TODO Tree" org-show-todo-tree t] 15875 ["Show TODO Tree" org-show-todo-tree t]
15767 ["Global TODO list" org-todo-list t] 15876 ["Global TODO list" org-todo-list t]
15768 "--" 15877 "--"
@@ -16042,31 +16151,32 @@ return nil."
16042 ;; In the paragraph separator we include headlines, because filling 16151 ;; In the paragraph separator we include headlines, because filling
16043 ;; text in a line directly attached to a headline would otherwise 16152 ;; text in a line directly attached to a headline would otherwise
16044 ;; fill the headline as well. 16153 ;; fill the headline as well.
16045 (set (make-local-variable 'comment-start-skip) "^#+[ \t]*") 16154 (org-set-local 'comment-start-skip "^#+[ \t]*")
16046 (set (make-local-variable 'paragraph-separate) "\f\\|\\*\\|[ ]*$\\|[ \t]*[:|]") 16155 (org-set-local 'paragraph-separate "\f\\|\\*\\|[ ]*$\\|[ \t]*[:|]")
16047 ;; The paragraph starter includes hand-formatted lists. 16156 ;; The paragraph starter includes hand-formatted lists.
16048 (set (make-local-variable 'paragraph-start) 16157 (org-set-local 'paragraph-start
16049 "\f\\|[ ]*$\\|\\([*\f]+\\)\\|[ \t]*\\([-+*][ \t]+\\|[0-9]+[.)][ \t]+\\)\\|[ \t]*[:|]") 16158 "\f\\|[ ]*$\\|\\([*\f]+\\)\\|[ \t]*\\([-+*][ \t]+\\|[0-9]+[.)][ \t]+\\)\\|[ \t]*[:|]")
16050 ;; Inhibit auto-fill for headers, tables and fixed-width lines. 16159 ;; Inhibit auto-fill for headers, tables and fixed-width lines.
16051 ;; But only if the user has not turned off tables or fixed-width regions 16160 ;; But only if the user has not turned off tables or fixed-width regions
16052 (set (make-local-variable 'auto-fill-inhibit-regexp) 16161 (org-set-local
16053 (concat "\\*\\|#" 16162 'auto-fill-inhibit-regexp
16054 "\\|[ \t]*" org-keyword-time-regexp 16163 (concat "\\*\\|#"
16055 (if (or org-enable-table-editor org-enable-fixed-width-editor) 16164 "\\|[ \t]*" org-keyword-time-regexp
16056 (concat 16165 (if (or org-enable-table-editor org-enable-fixed-width-editor)
16057 "\\|[ \t]*[" 16166 (concat
16058 (if org-enable-table-editor "|" "") 16167 "\\|[ \t]*["
16059 (if org-enable-fixed-width-editor ":" "") 16168 (if org-enable-table-editor "|" "")
16060 "]")))) 16169 (if org-enable-fixed-width-editor ":" "")
16170 "]"))))
16061 ;; We use our own fill-paragraph function, to make sure that tables 16171 ;; We use our own fill-paragraph function, to make sure that tables
16062 ;; and fixed-width regions are not wrapped. That function will pass 16172 ;; and fixed-width regions are not wrapped. That function will pass
16063 ;; through to `fill-paragraph' when appropriate. 16173 ;; through to `fill-paragraph' when appropriate.
16064 (set (make-local-variable 'fill-paragraph-function) 'org-fill-paragraph) 16174 (org-set-local 'fill-paragraph-function 'org-fill-paragraph)
16065 ;; Adaptive filling: To get full control, first make sure that 16175 ; Adaptive filling: To get full control, first make sure that
16066 ;; `adaptive-fill-regexp' never matches. Then install our own matcher. 16176 ;; `adaptive-fill-regexp' never matches. Then install our own matcher.
16067 (set (make-local-variable 'adaptive-fill-regexp) "\000") 16177 (org-set-local 'adaptive-fill-regexp "\000")
16068 (set (make-local-variable 'adaptive-fill-function) 16178 (org-set-local 'adaptive-fill-function
16069 'org-adaptive-fill-function)) 16179 'org-adaptive-fill-function))
16070 16180
16071(defun org-fill-paragraph (&optional justify) 16181(defun org-fill-paragraph (&optional justify)
16072 "Re-align a table, pass through to fill-paragraph if no table." 16182 "Re-align a table, pass through to fill-paragraph if no table."
@@ -16145,18 +16255,7 @@ that can be added."
16145 t) 16255 t)
16146 "\\'")))) 16256 "\\'"))))
16147 16257
16148;; Functions needed for compatibility with old outline.el. 16258;; Functions extending outline functionality
16149
16150;; Programming for the old outline.el (that uses selective display
16151;; instead of `invisible' text properties) is a nightmare, mostly
16152;; because regular expressions can no longer be anchored at
16153;; beginning/end of line. Therefore a number of function need special
16154;; treatment when the old outline.el is being used.
16155
16156;; The following functions capture almost the entire compatibility code
16157;; between the different versions of outline-mode. The only other
16158;; places where this is important are the font-lock-keywords, and in
16159;; `org-export-visible'. Search for `org-noutline-p' to find them.
16160 16259
16161;; C-a should go to the beginning of a *visible* line, also in the 16260;; C-a should go to the beginning of a *visible* line, also in the
16162;; new outline.el. I guess this should be patched into Emacs? 16261;; new outline.el. I guess this should be patched into Emacs?
@@ -16174,60 +16273,26 @@ to a visible line beginning. This makes the function of C-a more intuitive."
16174 (beginning-of-line 1)) 16273 (beginning-of-line 1))
16175 (forward-char 1)))) 16274 (forward-char 1))))
16176 16275
16177(when org-noutline-p 16276(define-key org-mode-map "\C-a" 'org-beginning-of-line)
16178 (define-key org-mode-map "\C-a" 'org-beginning-of-line))
16179 16277
16180(defun org-invisible-p () 16278(defun org-invisible-p ()
16181 "Check if point is at a character currently not visible." 16279 "Check if point is at a character currently not visible."
16182 (if org-noutline-p 16280 ;; Early versions of noutline don't have `outline-invisible-p'.
16183 ;; Early versions of noutline don't have `outline-invisible-p'. 16281 (if (fboundp 'outline-invisible-p)
16184 (if (fboundp 'outline-invisible-p) 16282 (outline-invisible-p)
16185 (outline-invisible-p) 16283 (get-char-property (point) 'invisible)))
16186 (get-char-property (point) 'invisible))
16187 (save-excursion
16188 (skip-chars-backward "^\r\n")
16189 (equal (char-before) ?\r))))
16190 16284
16191(defun org-invisible-p2 () 16285(defun org-invisible-p2 ()
16192 "Check if point is at a character currently not visible." 16286 "Check if point is at a character currently not visible."
16193 (save-excursion 16287 (save-excursion
16194 (if org-noutline-p 16288 (if (and (eolp) (not (bobp))) (backward-char 1))
16195 (progn 16289 ;; Early versions of noutline don't have `outline-invisible-p'.
16196 (if (and (eolp) (not (bobp))) (backward-char 1)) 16290 (if (fboundp 'outline-invisible-p)
16197 ;; Early versions of noutline don't have `outline-invisible-p'. 16291 (outline-invisible-p)
16198 (if (fboundp 'outline-invisible-p) 16292 (get-char-property (point) 'invisible))))
16199 (outline-invisible-p) 16293
16200 (get-char-property (point) 'invisible))) 16294(defalias 'org-back-to-heading 'outline-back-to-heading)
16201 (skip-chars-backward "^\r\n") 16295(defalias 'org-on-heading-p 'outline-on-heading-p)
16202 (equal (char-before) ?\r))))
16203
16204(defun org-back-to-heading (&optional invisible-ok)
16205 "Move to previous heading line, or beg of this line if it's a heading.
16206Only visible heading lines are considered, unless INVISIBLE-OK is non-nil."
16207 (if org-noutline-p
16208 (outline-back-to-heading invisible-ok)
16209 (if (and (or (bobp) (memq (char-before) '(?\n ?\r)))
16210 (looking-at outline-regexp))
16211 t
16212 (if (re-search-backward (concat (if invisible-ok "\\([\r\n]\\|^\\)" "^")
16213 outline-regexp)
16214 nil t)
16215 (if invisible-ok
16216 (progn (goto-char (or (match-end 1) (match-beginning 0)))
16217 (looking-at outline-regexp)))
16218 (error "Before first heading")))))
16219
16220(defun org-on-heading-p (&optional invisible-ok)
16221 "Return t if point is on a (visible) heading line.
16222If INVISIBLE-OK is non-nil, an invisible heading line is ok too."
16223 (if org-noutline-p
16224 (outline-on-heading-p 'invisible-ok)
16225 (save-excursion
16226 (skip-chars-backward "^\n\r")
16227 (and (looking-at outline-regexp)
16228 (or invisible-ok
16229 (bobp)
16230 (equal (char-before) ?\n))))))
16231 16296
16232(defun org-on-target-p () 16297(defun org-on-target-p ()
16233 (let ((pos (point))) 16298 (let ((pos (point)))
@@ -16243,47 +16308,20 @@ If INVISIBLE-OK is non-nil, an invisible heading line is ok too."
16243 "Move to the heading line of which the present line is a subheading. 16308 "Move to the heading line of which the present line is a subheading.
16244This function considers both visible and invisible heading lines. 16309This function considers both visible and invisible heading lines.
16245With argument, move up ARG levels." 16310With argument, move up ARG levels."
16246 (if org-noutline-p 16311 (if (fboundp 'outline-up-heading-all)
16247 (if (fboundp 'outline-up-heading-all) 16312 (outline-up-heading-all arg) ; emacs 21 version of outline.el
16248 (outline-up-heading-all arg) ; emacs 21 version of outline.el 16313 (outline-up-heading arg t))) ; emacs 22 version of outline.el
16249 (outline-up-heading arg t)) ; emacs 22 version of outline.el
16250 (org-back-to-heading t)
16251 (looking-at outline-regexp)
16252 (if (<= (- (match-end 0) (match-beginning 0)) arg)
16253 (error "Cannot move up %d levels" arg)
16254 (re-search-backward
16255 (concat "[\n\r]" (regexp-quote
16256 (make-string (- (match-end 0) (match-beginning 0) arg)
16257 ?*))
16258 "[^*]"))
16259 (forward-char 1))))
16260 16314
16261(defun org-show-hidden-entry () 16315(defun org-show-hidden-entry ()
16262 "Show an entry where even the heading is hidden." 16316 "Show an entry where even the heading is hidden."
16263 (save-excursion 16317 (save-excursion
16264 (if (not org-noutline-p)
16265 (progn
16266 (org-back-to-heading t)
16267 (org-flag-heading nil)))
16268 (org-show-entry))) 16318 (org-show-entry)))
16269 16319
16270(defun org-check-occur-regexp (regexp)
16271 "If REGEXP starts with \"^\", modify it to check for \\r as well.
16272Of course, only for the old outline mode."
16273 (if org-noutline-p
16274 regexp
16275 (if (string-match "^\\^" regexp)
16276 (concat "[\n\r]" (substring regexp 1))
16277 regexp)))
16278
16279(defun org-flag-heading (flag &optional entry) 16320(defun org-flag-heading (flag &optional entry)
16280 "Flag the current heading. FLAG non-nil means make invisible. 16321 "Flag the current heading. FLAG non-nil means make invisible.
16281When ENTRY is non-nil, show the entire entry." 16322When ENTRY is non-nil, show the entire entry."
16282 (save-excursion 16323 (save-excursion
16283 (org-back-to-heading t) 16324 (org-back-to-heading t)
16284 (if (not org-noutline-p)
16285 ;; Make the current headline visible
16286 (outline-flag-region (max 1 (1- (point))) (point) (if flag ?\r ?\n)))
16287 ;; Check if we should show the entire entry 16325 ;; Check if we should show the entire entry
16288 (if entry 16326 (if entry
16289 (progn 16327 (progn
@@ -16293,9 +16331,7 @@ When ENTRY is non-nil, show the entire entry."
16293 (org-flag-heading nil)))) 16331 (org-flag-heading nil))))
16294 (outline-flag-region (max 1 (1- (point))) 16332 (outline-flag-region (max 1 (1- (point)))
16295 (save-excursion (outline-end-of-heading) (point)) 16333 (save-excursion (outline-end-of-heading) (point))
16296 (if org-noutline-p 16334 flag))))
16297 flag
16298 (if flag ?\r ?\n))))))
16299 16335
16300(defun org-end-of-subtree (&optional invisible-OK) 16336(defun org-end-of-subtree (&optional invisible-OK)
16301 ;; This is an exact copy of the original function, but it uses 16337 ;; This is an exact copy of the original function, but it uses
@@ -16324,7 +16360,7 @@ When ENTRY is non-nil, show the entire entry."
16324 (point) 16360 (point)
16325 (save-excursion 16361 (save-excursion
16326 (outline-end-of-subtree) (outline-next-heading) (point)) 16362 (outline-end-of-subtree) (outline-next-heading) (point))
16327 (if org-noutline-p nil ?\n))) 16363 nil))
16328 16364
16329(defun org-show-entry () 16365(defun org-show-entry ()
16330 "Show the body directly following this heading. 16366 "Show the body directly following this heading.
@@ -16337,16 +16373,16 @@ Show the heading too, if it is currently invisible."
16337 (save-excursion 16373 (save-excursion
16338 (re-search-forward (concat "[\r\n]\\(" outline-regexp "\\)") nil 'move) 16374 (re-search-forward (concat "[\r\n]\\(" outline-regexp "\\)") nil 'move)
16339 (or (match-beginning 1) (point-max))) 16375 (or (match-beginning 1) (point-max)))
16340 (if org-noutline-p nil ?\n)))) 16376 nil)))
16341 16377
16342(defun org-make-options-regexp (kwds) 16378(defun org-make-options-regexp (kwds)
16343 "Make a regular expression for keyword lines." 16379 "Make a regular expression for keyword lines."
16344 (concat 16380 (concat
16345 (if org-noutline-p "^" "[\n\r]") 16381 "^"
16346 "#?[ \t]*\\+\\(" 16382 "#?[ \t]*\\+\\("
16347 (mapconcat 'regexp-quote kwds "\\|") 16383 (mapconcat 'regexp-quote kwds "\\|")
16348 "\\):[ \t]*" 16384 "\\):[ \t]*"
16349 (if org-noutline-p "\\(.+\\)" "\\([^\n\r]+\\)"))) 16385 "\\(.+\\)"))
16350 16386
16351;; Make `bookmark-jump' show the jump location if it was hidden. 16387;; Make `bookmark-jump' show the jump location if it was hidden.
16352(eval-after-load "bookmark" 16388(eval-after-load "bookmark"