Mercurial > emacs
comparison lisp/textmodes/org.el @ 72398:1c9c6dd0b6d3
(org-clock-special-range, org-clock-update-time-maybe):
New functions.
(org-stamp-time-of-day-regexp): Allow weekday to be of word chars,
not only a-z.
(org-agenda-get-blocks): Allow multiple blocks per headline.
(org-timestamp-change): Call `org-clock-update-time-maybe'.
(org-export-html-title-format)
(org-export-html-toplevel-hlevel): New options.
(org-export-language-setup): Added support for Czech.
(org-mode, org-insert-todo-heading, org-find-visible)
(org-find-invisible, org-invisible-p, org-invisible-p2)
(org-back-to-heading, org-on-heading-p, org-up-heading-all)
(org-show-subtree, org-show-entry, org-make-options-regexp):
Removed compatibility support for old outline-mode.
(org-check-occur-regexp): Funtion removed.
(org-on-heading-p, org-back-to-heading): Made defalias.
(org-set-local): New defsubst.
(org-set-regexps-and-options, org-mode)
(org-set-font-lock-defaults, org-edit-agenda-file-list)
(org-timeline, org-agenda-list, org-todo-list, org-tags-view)
(org-remember-apply-template, org-table-edit-field)
(org-table-edit-formulas, orgtbl-mode, org-export-as-ascii)
(org-set-autofill-regexps): Use `org-set-local'.
(org-table-eval-formula): Fixed bug with parsing of display flags.
author | Carsten Dominik <dominik@science.uva.nl> |
---|---|
date | Tue, 15 Aug 2006 11:55:38 +0000 |
parents | 4df24233cf1e |
children | 37bdcb1f6e30 7f3f771c85fa |
comparison
equal
deleted
inserted
replaced
72397:11e68a34a4bd | 72398:1c9c6dd0b6d3 |
---|---|
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.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 ;; |
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.44 | |
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. | |
97 ;; | |
93 ;; Version 4.43 | 98 ;; Version 4.43 |
94 ;; - Big fixes | |
95 ;; | |
96 ;; Version 4.42 | |
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 ;; |
100 ;; Version 4.41 | 102 ;; Version 4.41 |
101 ;; - Shift-curser keys can modify inactive time stamps (inactive time | 103 ;; - Shift-curser keys can modify inactive time stamps (inactive time |
210 (require 'time-date) | 212 (require 'time-date) |
211 (require 'easymenu) | 213 (require 'easymenu) |
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")) |
228 (add-text-properties 0 1 '(test t) x) | 227 (add-text-properties 0 1 '(test t) x) |
229 (get-text-property 0 'test (format "%s" x))) | 228 (get-text-property 0 'test (format "%s" x))) |
1130 extension. The entries in this list are cons cells where the car identifies | 1129 extension. The entries in this list are cons cells where the car identifies |
1131 files and the cdr the corresponding command. Possible values for the | 1130 files and the cdr the corresponding command. Possible values for the |
1132 file identifier are | 1131 file 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 |
1139 | 1138 |
1140 Possible values for the command are: | 1139 Possible values for the command are: |
1829 (const :html) (const :ascii) (const :ical) (const :xoxo)) | 1828 (const :html) (const :ascii) (const :ical) (const :xoxo)) |
1830 (directory))))) | 1829 (directory))))) |
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") |
1837 ("fr" "Auteur" "Date" "Table des Mati\xe8res") | 1837 ("fr" "Auteur" "Date" "Table des Mati\xe8res") |
1838 ("it" "Autore" "Data" "Indice") | 1838 ("it" "Autore" "Data" "Indice") |
2145 | 2145 |
2146 <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\"> | 2146 <link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\"> |
2147 | 2147 |
2148 As the value of this option simply gets inserted into the HTML <head> header, | 2148 As the value of this option simply gets inserted into the HTML <head> header, |
2149 you can \"misuse\" it to add arbitrary text to the header." | 2149 you can \"misuse\" it to add arbitrary text to the header." |
2150 :group 'org-export-html | |
2151 :type 'string) | |
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." | |
2150 :group 'org-export-html | 2160 :group 'org-export-html |
2151 :type 'string) | 2161 :type 'string) |
2152 | 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'. |
2692 | 2702 |
2693 (defsubst org-no-properties (s) | 2703 (defsubst org-no-properties (s) |
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)) |
2700 | 2714 |
2701 (defun org-set-regexps-and-options () | 2715 (defun org-set-regexps-and-options () |
2702 "Precompute regular expressions for current buffer." | 2716 "Precompute regular expressions for current buffer." |
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 |
2710 (save-restriction | 2724 (save-restriction |
2711 (widen) | 2725 (widen) |
2753 (string-match " *$" value) | 2767 (string-match " *$" value) |
2754 (setq arch (replace-match "" t t value)) | 2768 (setq arch (replace-match "" t t value)) |
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)) |
2765 (cond | 2779 (cond |
2766 ((equal e "{") (push '(:startgroup) tgs)) | 2780 ((equal e "{") (push '(:startgroup) tgs)) |
2768 ((string-match "^\\([0-9a-zA-Z_@]+\\)(\\(.\\))$" e) | 2782 ((string-match "^\\([0-9a-zA-Z_@]+\\)(\\(.\\))$" e) |
2769 (push (cons (match-string 1 e) | 2783 (push (cons (match-string 1 e) |
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)) |
2777 (push e org-tag-alist)))))) | 2791 (push e org-tag-alist)))))) |
2778 | 2792 |
2926 | 2940 |
2927 ;; Get rid of Outline menus, they are not needed | 2941 ;; Get rid of Outline menus, they are not needed |
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)) |
2943 | 2953 |
2944 (easy-menu-add org-org-menu) | 2954 (easy-menu-add org-org-menu) |
2945 (easy-menu-add org-tbl-menu) | 2955 (easy-menu-add org-tbl-menu) |
2946 (org-install-agenda-files-menu) | 2956 (org-install-agenda-files-menu) |
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) |
2954 (when (and org-ellipsis (stringp org-ellipsis)) | 2964 (when (and org-ellipsis (stringp org-ellipsis)) |
2955 (unless org-display-table | 2965 (unless org-display-table |
2956 (setq org-display-table (make-display-table))) | 2966 (setq org-display-table (make-display-table))) |
2957 (set-display-table-slot org-display-table | 2967 (set-display-table-slot org-display-table |
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 |
2970 (org-add-hook 'kill-buffer-hook 'org-check-running-clock nil 'local) | 2982 (org-add-hook 'kill-buffer-hook 'org-check-running-clock nil 'local) |
2971 ;; Paragraphs and auto-filling | 2983 ;; Paragraphs and auto-filling |
3105 "Regular expression matching a time stamp range.") | 3117 "Regular expression matching a time stamp range.") |
3106 (defconst org-tsr-regexp (concat org-ts-regexp "\\(--?-?" | 3118 (defconst org-tsr-regexp (concat org-ts-regexp "\\(--?-?" |
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." |
3114 (if (re-search-forward org-emph-re limit t) | 3126 (if (re-search-forward org-emph-re limit t) |
3115 (progn | 3127 (progn |
3338 '("| *\\(<[0-9]+>\\) *" (1 'org-formula t))) | 3350 '("| *\\(<[0-9]+>\\) *" (1 'org-formula t))) |
3339 '("^\\*+ \\(.*:ARCHIVE:.*\\)" (1 'org-archived prepend)) | 3351 '("^\\*+ \\(.*:ARCHIVE:.*\\)" (1 'org-archived prepend)) |
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) |
3350 (defvar org-l nil) | 3361 (defvar org-l nil) |
3351 (defvar org-f nil) | 3362 (defvar org-f nil) |
3810 (interactive "P") | 3821 (interactive "P") |
3811 (when (not (org-insert-item 'checkbox)) | 3822 (when (not (org-insert-item 'checkbox)) |
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)) |
3821 (equal (match-string 2) org-done-string)) | 3830 (equal (match-string 2) org-done-string)) |
3822 (insert (car org-todo-keywords) " ") | 3831 (insert (car org-todo-keywords) " ") |
4701 (interactive) | 4710 (interactive) |
4702 (let ((pa '(:org-archived t)) | 4711 (let ((pa '(:org-archived t)) |
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) |
4710 (set-buffer (org-get-agenda-file-buffer file)) | 4719 (set-buffer (org-get-agenda-file-buffer file)) |
4711 (widen) | 4720 (widen) |
4773 (match-beginning 0)))) | 4782 (match-beginning 0)))) |
4774 (if pos (goto-char pos)) | 4783 (if pos (goto-char pos)) |
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]\\|$\\)" |
4782 "Matches the end of a dyhamic block.") | 4791 "Matches the end of a dyhamic block.") |
4783 | 4792 |
4801 (unless (looking-at org-dblock-start-re) | 4810 (unless (looking-at org-dblock-start-re) |
4802 (error "Not at a dynamic block")) | 4811 (error "Not at a dynamic block")) |
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)) |
4810 (goto-char begdel) | 4819 (goto-char begdel) |
4811 (open-line 1) | 4820 (open-line 1) |
5198 to make sure editing the matching entry is easy. | 5207 to make sure editing the matching entry is easy. |
5199 If CALLBACK is non-nil, it is a function which is called to confirm | 5208 If CALLBACK is non-nil, it is a function which is called to confirm |
5200 that the match should indeed be shown." | 5209 that 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)) |
5207 (org-overview) | 5215 (org-overview) |
5208 (while (re-search-forward regexp nil t) | 5216 (while (re-search-forward regexp nil t) |
5623 If the time range is actually in a table, the result is inserted into the | 5631 If the time range is actually in a table, the result is inserted into the |
5624 next column. | 5632 next column. |
5625 For time difference computation, a year is assumed to be exactly 365 | 5633 For time difference computation, a year is assumed to be exactly 365 |
5626 days in order to avoid rounding problems." | 5634 days 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 "") |
5681 (l nil)) | 5691 (l nil)) |
5682 (if (> y 0) (setq fmt (concat fmt "%d year" (if (> y 1) "s" "") " ") | 5692 (if (> y 0) (setq fmt (concat fmt "%d year" (if (> y 1) "s" "") " ") |
5815 (setcar time0 (or (car time0) 0)) | 5825 (setcar time0 (or (car time0) 0)) |
5816 (setcar (nthcdr 1 time0) (or (nth 1 time0) 0)) | 5826 (setcar (nthcdr 1 time0) (or (nth 1 time0) 0)) |
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 |
5823 (get-buffer-window "*Calendar*" t) | 5834 (get-buffer-window "*Calendar*" t) |
5824 (memq org-ts-what '(day month year))) | 5835 (memq org-ts-what '(day month year))) |
5935 | 5946 |
5936 (defvar org-clock-file-total-minutes nil | 5947 (defvar org-clock-file-total-minutes nil |
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. |
5942 Puts the resulting times in minutes as a text property on each headline." | 5953 Puts 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 |
5955 (goto-char (point-max)) | 5967 (goto-char (point-max)) |
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)) |
5964 (loop for l from 0 to level do | 5984 (loop for l from 0 to level do |
5965 (aset ltimes l (+ (aref ltimes l) t1))) | 5985 (aset ltimes l (+ (aref ltimes l) t1))) |
6067 :maxlevel The maximum level to be included in the table. Default is 3. | 6087 :maxlevel The maximum level to be included in the table. Default is 3. |
6068 :emphasize t/nil, if levell 1 and level 2 should be bold/italic in the table." | 6088 :emphasize t/nil, if levell 1 and level 2 should be bold/italic in the table." |
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)) |
6095 | |
6096 (defun org-clock-update-time-maybe () | |
6097 "If this is a CLOCK line, update it and return t. | |
6098 Otherwise, 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. | |
6127 Key is a symbol specifying the range and can be one of `today', `yesterday', | |
6128 `thisweek', `lastweek', `thismonth', `lastmonth', `thisyear', `lastyear'. | |
6129 A week starts Monday 0:00 and ends Sunday 24:00. | |
6130 The range is determined relative to TIME. TIME defaults to the current time. | |
6131 The return value is a cons cell with two internal times like the ones | |
6132 returned by `current time' or `encode-time'. if AS-STRINGS is non-nil, | |
6133 the 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)))) | |
6075 | 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*| " |
6095 (format "*%d:%02d*" h m) | 6201 (format "*%d:%02d*" h m) |
6096 "|\n") | 6202 "|\n") |
6473 the buffer and restores the previous window configuration." | 6579 the buffer and restores the previous window configuration." |
6474 (interactive) | 6580 (interactive) |
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 |
6482 (prog1 org-window-configuration | 6588 (prog1 org-window-configuration |
6483 (kill-buffer (current-buffer)))) | 6589 (kill-buffer (current-buffer)))) |
6601 (switch-to-buffer-other-window | 6707 (switch-to-buffer-other-window |
6602 (get-buffer-create org-agenda-buffer-name)) | 6708 (get-buffer-create org-agenda-buffer-name)) |
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)) |
6610 (while (setq d (pop day-numbers)) | 6716 (while (setq d (pop day-numbers)) |
6611 (if (and (listp d) (eq (car d) :omitted)) | 6717 (if (and (listp d) (eq (car d) :omitted)) |
6699 (switch-to-buffer-other-window | 6805 (switch-to-buffer-other-window |
6700 (get-buffer-create org-agenda-buffer-name)))) | 6806 (get-buffer-create org-agenda-buffer-name)))) |
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 |
6710 rtnall nil) | 6816 rtnall nil) |
6711 (while (setq file (pop files)) | 6817 (while (setq file (pop files)) |
6810 (switch-to-buffer-other-window | 6916 (switch-to-buffer-other-window |
6811 (get-buffer-create org-agenda-buffer-name)))) | 6917 (get-buffer-create org-agenda-buffer-name)))) |
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) |
6823 (while (setq file (pop files)) | 6929 (while (setq file (pop files)) |
6824 (catch 'nextfile | 6930 (catch 'nextfile |
7702 'help-echo | 7808 'help-echo |
7703 (format "mouse-2 or RET jump to org file %s" | 7809 (format "mouse-2 or RET jump to org file %s" |
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) |
7715 d1 (time-to-days (org-time-string-to-time s1)) | 7822 d1 (time-to-days (org-time-string-to-time s1)) |
7716 d2 (time-to-days (org-time-string-to-time s2))) | 7823 d2 (time-to-days (org-time-string-to-time s2))) |
7734 (setq txt org-agenda-no-heading-message)) | 7841 (setq txt org-agenda-no-heading-message)) |
7735 (org-add-props txt props | 7842 (org-add-props txt props |
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 |
7743 (defconst org-plain-time-of-day-regexp | 7851 (defconst org-plain-time-of-day-regexp |
7744 (concat | 7852 (concat |
7755 1 the first time, range or not | 7863 1 the first time, range or not |
7756 8 the second time, if it is a range.") | 7864 8 the second time, if it is a range.") |
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]\\)>\\)?") |
7764 "Regular expression to match a timestamp time or time range. | 7872 "Regular expression to match a timestamp time or time range. |
7765 After a match, the following groups carry important information: | 7873 After a match, the following groups carry important information: |
8618 (switch-to-buffer-other-window | 8726 (switch-to-buffer-other-window |
8619 (get-buffer-create org-agenda-buffer-name)))) | 8727 (get-buffer-create org-agenda-buffer-name)))) |
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) |
8630 (while (setq file (pop files)) | 8738 (while (setq file (pop files)) |
8631 (catch 'nextfile | 8739 (catch 'nextfile |
10232 t t)) | 10340 t t)) |
10233 (let ((org-startup-folded nil) | 10341 (let ((org-startup-folded nil) |
10234 (org-startup-with-deadline-check nil)) | 10342 (org-startup-with-deadline-check nil)) |
10235 (org-mode)) | 10343 (org-mode)) |
10236 (if (and file (string-match "\\S-" file) (not (file-directory-p file))) | 10344 (if (and file (string-match "\\S-" file) (not (file-directory-p file))) |
10237 (set (make-local-variable 'org-default-notes-file) file)) | 10345 (org-set-local 'org-default-notes-file file)) |
10238 (goto-char (point-min)) | 10346 (goto-char (point-min)) |
10239 (if (re-search-forward "%\\?" nil t) (replace-match ""))) | 10347 (if (re-search-forward "%\\?" nil t) (replace-match ""))) |
10240 (let ((org-startup-folded nil) | 10348 (let ((org-startup-folded nil) |
10241 (org-startup-with-deadline-check nil)) | 10349 (org-startup-with-deadline-check nil)) |
10242 (org-mode))) | 10350 (org-mode))) |
10243 (set (make-local-variable 'org-finish-function) 'remember-buffer)) | 10351 (org-set-local 'org-finish-function 'remember-buffer)) |
10244 | 10352 |
10245 ;;;###autoload | 10353 ;;;###autoload |
10246 (defun org-remember-handler () | 10354 (defun org-remember-handler () |
10247 "Store stuff from remember.el into an org file. | 10355 "Store stuff from remember.el into an org file. |
10248 First prompts for an org file. If the user just presses return, the value | 10356 First prompts for an org file. If the user just presses return, the value |
11490 (insert (org-trim field)) | 11598 (insert (org-trim field)) |
11491 (remove-text-properties p (point-max) | 11599 (remove-text-properties p (point-max) |
11492 '(invisible t org-cwidth t display t | 11600 '(invisible t org-cwidth t display t |
11493 intangible t)) | 11601 intangible t)) |
11494 (goto-char p) | 11602 (goto-char p) |
11495 (set (make-local-variable 'org-finish-function) | 11603 (org-set-local 'org-finish-function |
11496 'org-table-finish-edit-field) | 11604 'org-table-finish-edit-field) |
11497 (set (make-local-variable 'org-window-configuration) cw) | 11605 (org-set-local 'org-window-configuration cw) |
11498 (set (make-local-variable 'org-field-marker) pos) | 11606 (org-set-local 'org-field-marker pos) |
11499 (message "Edit and finish with C-c C-c")))) | 11607 (message "Edit and finish with C-c C-c")))) |
11500 | 11608 |
11501 (defun org-table-finish-edit-field () | 11609 (defun org-table-finish-edit-field () |
11502 "Finish editing a table data field. | 11610 "Finish editing a table data field. |
11503 Remove all newline characters, insert the result into the table, realign | 11611 Remove all newline characters, insert the result into the table, realign |
12096 (if (string-match ";" formula) | 12204 (if (string-match ";" formula) |
12097 (let ((tmp (org-split-string formula ";"))) | 12205 (let ((tmp (org-split-string formula ";"))) |
12098 (setq formula (car tmp) | 12206 (setq formula (car tmp) |
12099 fmt (concat (cdr (assoc "%" org-table-local-parameters)) | 12207 fmt (concat (cdr (assoc "%" org-table-local-parameters)) |
12100 (nth 1 tmp))) | 12208 (nth 1 tmp))) |
12101 (while (string-match "[pnfse]\\(-?[0-9]+\\)" fmt) | 12209 (while (string-match "\\([pnfse]\\)\\(-?[0-9]+\\)" fmt) |
12102 (setq c (string-to-char (match-string 1 fmt)) | 12210 (setq c (string-to-char (match-string 1 fmt)) |
12103 n (string-to-number (or (match-string 1 fmt) ""))) | 12211 n (string-to-number (match-string 2 fmt))) |
12104 (if (= c ?p) (setq modes (org-set-calc-mode 'calc-internal-prec n)) | 12212 (if (= c ?p) |
12213 (setq modes (org-set-calc-mode 'calc-internal-prec n)) | |
12105 (setq modes (org-set-calc-mode | 12214 (setq modes (org-set-calc-mode |
12106 'calc-float-format | 12215 'calc-float-format |
12107 (list (cdr (assoc c '((?n . float) (?f . fix) | 12216 (list (cdr (assoc c '((?n . float) (?f . fix) |
12108 (?s . sci) (?e . eng)))) | 12217 (?s . sci) (?e . eng)))) |
12109 n)))) | 12218 n)))) |
12312 (wc (current-window-configuration)) | 12421 (wc (current-window-configuration)) |
12313 entry loc s) | 12422 entry loc s) |
12314 (switch-to-buffer-other-window "*Edit Formulas*") | 12423 (switch-to-buffer-other-window "*Edit Formulas*") |
12315 (erase-buffer) | 12424 (erase-buffer) |
12316 (fundamental-mode) | 12425 (fundamental-mode) |
12317 (set (make-local-variable 'org-pos) pos) | 12426 (org-set-local 'org-pos pos) |
12318 (set (make-local-variable 'org-window-configuration) wc) | 12427 (org-set-local 'org-window-configuration wc) |
12319 (use-local-map org-edit-formulas-map) | 12428 (use-local-map org-edit-formulas-map) |
12320 (setq s "# Edit formulas and finish with `C-c C-c'. | 12429 (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. | 12430 # Use `C-u C-c C-c' to also appy them immediately to the entire table. |
12322 # Use `C-c ?' to get information about $name at point. | 12431 # Use `C-c ?' to get information about $name at point. |
12323 # To cancel editing, press `C-c C-q'.\n") | 12432 # To cancel editing, press `C-c C-q'.\n") |
12479 (and (orgtbl-setup) (defun orgtbl-setup () nil)) | 12588 (and (orgtbl-setup) (defun orgtbl-setup () nil)) |
12480 ;; Make sure we are first in minor-mode-map-alist | 12589 ;; Make sure we are first in minor-mode-map-alist |
12481 (let ((c (assq 'orgtbl-mode minor-mode-map-alist))) | 12590 (let ((c (assq 'orgtbl-mode minor-mode-map-alist))) |
12482 (and c (setq minor-mode-map-alist | 12591 (and c (setq minor-mode-map-alist |
12483 (cons c (delq c minor-mode-map-alist))))) | 12592 (cons c (delq c minor-mode-map-alist))))) |
12484 (set (make-local-variable (quote org-table-may-need-update)) t) | 12593 (org-set-local (quote org-table-may-need-update) t) |
12485 (org-add-hook 'before-change-functions 'org-before-change-function | 12594 (org-add-hook 'before-change-functions 'org-before-change-function |
12486 nil 'local) | 12595 nil 'local) |
12487 (set (make-local-variable 'org-old-auto-fill-inhibit-regexp) | 12596 (org-set-local 'org-old-auto-fill-inhibit-regexp |
12488 auto-fill-inhibit-regexp) | 12597 auto-fill-inhibit-regexp) |
12489 (set (make-local-variable 'auto-fill-inhibit-regexp) | 12598 (org-set-local 'auto-fill-inhibit-regexp |
12490 (if auto-fill-inhibit-regexp | 12599 (if auto-fill-inhibit-regexp |
12491 (concat "\\([ \t]*|\\|" auto-fill-inhibit-regexp) | 12600 (concat "\\([ \t]*|\\|" auto-fill-inhibit-regexp) |
12492 "[ \t]*|")) | 12601 "[ \t]*|")) |
12493 (org-add-to-invisibility-spec '(org-cwidth)) | 12602 (org-add-to-invisibility-spec '(org-cwidth)) |
12494 (easy-menu-add orgtbl-mode-menu) | 12603 (easy-menu-add orgtbl-mode-menu) |
12495 (run-hooks 'orgtbl-mode-hook)) | 12604 (run-hooks 'orgtbl-mode-hook)) |
12496 (setq auto-fill-inhibit-regexp org-old-auto-fill-inhibit-regexp) | 12605 (setq auto-fill-inhibit-regexp org-old-auto-fill-inhibit-regexp) |
12497 (org-cleanup-narrow-column-properties) | 12606 (org-cleanup-narrow-column-properties) |
13386 ;; functions get the correct information | 13495 ;; functions get the correct information |
13387 (mapcar (lambda (x) | 13496 (mapcar (lambda (x) |
13388 (set (make-local-variable (cdr x)) | 13497 (set (make-local-variable (cdr x)) |
13389 (plist-get opt-plist (car x)))) | 13498 (plist-get opt-plist (car x)))) |
13390 org-export-plist-vars) | 13499 org-export-plist-vars) |
13391 (set (make-local-variable 'org-odd-levels-only) odd) | 13500 (org-set-local 'org-odd-levels-only odd) |
13392 (setq umax (if arg (prefix-numeric-value arg) | 13501 (setq umax (if arg (prefix-numeric-value arg) |
13393 org-export-headline-levels)) | 13502 org-export-headline-levels)) |
13394 | 13503 |
13395 ;; File header | 13504 ;; File header |
13396 (if title (org-insert-centered title ?=)) | 13505 (if title (org-insert-centered title ?=)) |
13592 (kill-buffer buffer) | 13701 (kill-buffer buffer) |
13593 (switch-to-buffer-other-window buffer) | 13702 (switch-to-buffer-other-window buffer) |
13594 (goto-char (point-min))))) | 13703 (goto-char (point-min))))) |
13595 | 13704 |
13596 (defun org-find-visible () | 13705 (defun org-find-visible () |
13597 (if (featurep 'noutline) | 13706 (let ((s (point))) |
13598 (let ((s (point))) | 13707 (while (and (not (= (point-max) (setq s (next-overlay-change s)))) |
13599 (while (and (not (= (point-max) (setq s (next-overlay-change s)))) | 13708 (get-char-property s 'invisible))) |
13600 (get-char-property s 'invisible))) | 13709 s)) |
13601 s) | |
13602 (skip-chars-forward "^\n") | |
13603 (point))) | |
13604 (defun org-find-invisible () | 13710 (defun org-find-invisible () |
13605 (if (featurep 'noutline) | 13711 (let ((s (point))) |
13606 (let ((s (point))) | 13712 (while (and (not (= (point-max) (setq s (next-overlay-change s)))) |
13607 (while (and (not (= (point-max) (setq s (next-overlay-change s)))) | 13713 (not (get-char-property s 'invisible)))) |
13608 (not (get-char-property s 'invisible)))) | 13714 s)) |
13609 s) | |
13610 (skip-chars-forward "^\r") | |
13611 (point))) | |
13612 | |
13613 | 13715 |
13614 ;; HTML | 13716 ;; HTML |
13615 | 13717 |
13616 (defun org-get-current-options () | 13718 (defun org-get-current-options () |
13617 "Return a string with current options as keyword options. | 13719 "Return a string with current options as keyword options. |
13857 | 13959 |
13858 | 13960 |
13859 (insert (or (plist-get opt-plist :preamble) "")) | 13961 (insert (or (plist-get opt-plist :preamble) "")) |
13860 | 13962 |
13861 (when (plist-get opt-plist :auto-preamble) | 13963 (when (plist-get opt-plist :auto-preamble) |
13862 (if title (insert (concat "<h1 class=\"title\">" | 13964 (if title (insert (format org-export-html-title-format |
13863 (org-html-expand title) "</h1>\n"))) | 13965 (org-html-expand title)))) |
13864 | |
13865 (if text (insert "<p>\n" (org-html-expand text) "</p>"))) | 13966 (if text (insert "<p>\n" (org-html-expand text) "</p>"))) |
13866 | 13967 |
13867 (if org-export-with-toc | 13968 (if org-export-with-toc |
13868 (progn | 13969 (progn |
13869 (insert (format "<h2>%s</h2>\n" (nth 3 lang-words))) | 13970 (insert (format "<h%d>%s</h%d>\n" |
13971 org-export-html-toplevel-hlevel | |
13972 (nth 3 lang-words) | |
13973 org-export-html-toplevel-hlevel)) | |
13870 (insert "<ul>\n<li>") | 13974 (insert "<ul>\n<li>") |
13871 (setq lines | 13975 (setq lines |
13872 (mapcar '(lambda (line) | 13976 (mapcar '(lambda (line) |
13873 (if (string-match org-todo-line-regexp line) | 13977 (if (string-match org-todo-line-regexp line) |
13874 ;; This is a headline | 13978 ;; This is a headline |
14551 (aset levels-open (1- level) t) | 14655 (aset levels-open (1- level) t) |
14552 (org-close-par-maybe) | 14656 (org-close-par-maybe) |
14553 (insert "<ul>\n<li>" title "<br/>\n"))) | 14657 (insert "<ul>\n<li>" title "<br/>\n"))) |
14554 (if org-export-with-section-numbers | 14658 (if org-export-with-section-numbers |
14555 (setq title (concat (org-section-number level) " " title))) | 14659 (setq title (concat (org-section-number level) " " title))) |
14556 (setq level (+ level 1)) | 14660 (setq level (+ level org-export-html-toplevel-hlevel -1)) |
14557 (if with-toc | 14661 (if with-toc |
14558 (insert (format "\n<h%d><a name=\"sec-%d\">%s</a></h%d>\n" | 14662 (insert (format "\n<h%d><a name=\"sec-%d\">%s</a></h%d>\n" |
14559 level head-count title level)) | 14663 level head-count title level)) |
14560 (insert (format "\n<h%d>%s</h%d>\n" level title level))) | 14664 (insert (format "\n<h%d>%s</h%d>\n" level title level))) |
14561 (org-open-par))))) | 14665 (org-open-par))))) |
15761 ["Check and Move Children" (org-archive-subtree '(4)) | 15865 ["Check and Move Children" (org-archive-subtree '(4)) |
15762 :active t :keys "C-u C-c $"]) | 15866 :active t :keys "C-u C-c $"]) |
15763 "--" | 15867 "--" |
15764 ("TODO Lists" | 15868 ("TODO Lists" |
15765 ["TODO/DONE/-" org-todo t] | 15869 ["TODO/DONE/-" org-todo t] |
15870 ("Select keyword" | |
15871 ["Next keyword" org-shiftright (org-on-heading-p)] | |
15872 ["Previous keyword" org-shiftleft (org-on-heading-p)] | |
15873 ["Complete Keyword" org-complete (assq :todo-keyword (org-context))]) | |
15766 ["Show TODO Tree" org-show-todo-tree t] | 15874 ["Show TODO Tree" org-show-todo-tree t] |
15767 ["Global TODO list" org-todo-list t] | 15875 ["Global TODO list" org-todo-list t] |
15768 "--" | 15876 "--" |
15769 ["Set Priority" org-priority t] | 15877 ["Set Priority" org-priority t] |
15770 ["Priority Up" org-shiftup t] | 15878 ["Priority Up" org-shiftup t] |
16040 (defun org-set-autofill-regexps () | 16148 (defun org-set-autofill-regexps () |
16041 (interactive) | 16149 (interactive) |
16042 ;; In the paragraph separator we include headlines, because filling | 16150 ;; In the paragraph separator we include headlines, because filling |
16043 ;; text in a line directly attached to a headline would otherwise | 16151 ;; text in a line directly attached to a headline would otherwise |
16044 ;; fill the headline as well. | 16152 ;; fill the headline as well. |
16045 (set (make-local-variable 'comment-start-skip) "^#+[ \t]*") | 16153 (org-set-local 'comment-start-skip "^#+[ \t]*") |
16046 (set (make-local-variable 'paragraph-separate) "\f\\|\\*\\|[ ]*$\\|[ \t]*[:|]") | 16154 (org-set-local 'paragraph-separate "\f\\|\\*\\|[ ]*$\\|[ \t]*[:|]") |
16047 ;; The paragraph starter includes hand-formatted lists. | 16155 ;; The paragraph starter includes hand-formatted lists. |
16048 (set (make-local-variable 'paragraph-start) | 16156 (org-set-local 'paragraph-start |
16049 "\f\\|[ ]*$\\|\\([*\f]+\\)\\|[ \t]*\\([-+*][ \t]+\\|[0-9]+[.)][ \t]+\\)\\|[ \t]*[:|]") | 16157 "\f\\|[ ]*$\\|\\([*\f]+\\)\\|[ \t]*\\([-+*][ \t]+\\|[0-9]+[.)][ \t]+\\)\\|[ \t]*[:|]") |
16050 ;; Inhibit auto-fill for headers, tables and fixed-width lines. | 16158 ;; 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 | 16159 ;; But only if the user has not turned off tables or fixed-width regions |
16052 (set (make-local-variable 'auto-fill-inhibit-regexp) | 16160 (org-set-local |
16053 (concat "\\*\\|#" | 16161 'auto-fill-inhibit-regexp |
16054 "\\|[ \t]*" org-keyword-time-regexp | 16162 (concat "\\*\\|#" |
16055 (if (or org-enable-table-editor org-enable-fixed-width-editor) | 16163 "\\|[ \t]*" org-keyword-time-regexp |
16056 (concat | 16164 (if (or org-enable-table-editor org-enable-fixed-width-editor) |
16057 "\\|[ \t]*[" | 16165 (concat |
16058 (if org-enable-table-editor "|" "") | 16166 "\\|[ \t]*[" |
16059 (if org-enable-fixed-width-editor ":" "") | 16167 (if org-enable-table-editor "|" "") |
16060 "]")))) | 16168 (if org-enable-fixed-width-editor ":" "") |
16169 "]")))) | |
16061 ;; We use our own fill-paragraph function, to make sure that tables | 16170 ;; We use our own fill-paragraph function, to make sure that tables |
16062 ;; and fixed-width regions are not wrapped. That function will pass | 16171 ;; and fixed-width regions are not wrapped. That function will pass |
16063 ;; through to `fill-paragraph' when appropriate. | 16172 ;; through to `fill-paragraph' when appropriate. |
16064 (set (make-local-variable 'fill-paragraph-function) 'org-fill-paragraph) | 16173 (org-set-local 'fill-paragraph-function 'org-fill-paragraph) |
16065 ;; Adaptive filling: To get full control, first make sure that | 16174 ; Adaptive filling: To get full control, first make sure that |
16066 ;; `adaptive-fill-regexp' never matches. Then install our own matcher. | 16175 ;; `adaptive-fill-regexp' never matches. Then install our own matcher. |
16067 (set (make-local-variable 'adaptive-fill-regexp) "\000") | 16176 (org-set-local 'adaptive-fill-regexp "\000") |
16068 (set (make-local-variable 'adaptive-fill-function) | 16177 (org-set-local 'adaptive-fill-function |
16069 'org-adaptive-fill-function)) | 16178 'org-adaptive-fill-function)) |
16070 | 16179 |
16071 (defun org-fill-paragraph (&optional justify) | 16180 (defun org-fill-paragraph (&optional justify) |
16072 "Re-align a table, pass through to fill-paragraph if no table." | 16181 "Re-align a table, pass through to fill-paragraph if no table." |
16073 (let ((table-p (org-at-table-p)) | 16182 (let ((table-p (org-at-table-p)) |
16074 (table.el-p (org-at-table.el-p))) | 16183 (table.el-p (org-at-table.el-p))) |
16143 image-file-name-extensions) | 16252 image-file-name-extensions) |
16144 image-file-name-extensions) | 16253 image-file-name-extensions) |
16145 t) | 16254 t) |
16146 "\\'")))) | 16255 "\\'")))) |
16147 | 16256 |
16148 ;; Functions needed for compatibility with old outline.el. | 16257 ;; 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 | 16258 |
16161 ;; C-a should go to the beginning of a *visible* line, also in the | 16259 ;; 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? | 16260 ;; new outline.el. I guess this should be patched into Emacs? |
16163 (defun org-beginning-of-line () | 16261 (defun org-beginning-of-line () |
16164 "Go to the beginning of the current line. If that is invisible, continue | 16262 "Go to the beginning of the current line. If that is invisible, continue |
16172 (while (and (not (bobp)) (org-invisible-p)) | 16270 (while (and (not (bobp)) (org-invisible-p)) |
16173 (backward-char 1) | 16271 (backward-char 1) |
16174 (beginning-of-line 1)) | 16272 (beginning-of-line 1)) |
16175 (forward-char 1)))) | 16273 (forward-char 1)))) |
16176 | 16274 |
16177 (when org-noutline-p | 16275 (define-key org-mode-map "\C-a" 'org-beginning-of-line) |
16178 (define-key org-mode-map "\C-a" 'org-beginning-of-line)) | |
16179 | 16276 |
16180 (defun org-invisible-p () | 16277 (defun org-invisible-p () |
16181 "Check if point is at a character currently not visible." | 16278 "Check if point is at a character currently not visible." |
16182 (if org-noutline-p | 16279 ;; Early versions of noutline don't have `outline-invisible-p'. |
16183 ;; Early versions of noutline don't have `outline-invisible-p'. | 16280 (if (fboundp 'outline-invisible-p) |
16184 (if (fboundp 'outline-invisible-p) | 16281 (outline-invisible-p) |
16185 (outline-invisible-p) | 16282 (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 | 16283 |
16191 (defun org-invisible-p2 () | 16284 (defun org-invisible-p2 () |
16192 "Check if point is at a character currently not visible." | 16285 "Check if point is at a character currently not visible." |
16193 (save-excursion | 16286 (save-excursion |
16194 (if org-noutline-p | 16287 (if (and (eolp) (not (bobp))) (backward-char 1)) |
16195 (progn | 16288 ;; Early versions of noutline don't have `outline-invisible-p'. |
16196 (if (and (eolp) (not (bobp))) (backward-char 1)) | 16289 (if (fboundp 'outline-invisible-p) |
16197 ;; Early versions of noutline don't have `outline-invisible-p'. | 16290 (outline-invisible-p) |
16198 (if (fboundp 'outline-invisible-p) | 16291 (get-char-property (point) 'invisible)))) |
16199 (outline-invisible-p) | 16292 |
16200 (get-char-property (point) 'invisible))) | 16293 (defalias 'org-back-to-heading 'outline-back-to-heading) |
16201 (skip-chars-backward "^\r\n") | 16294 (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. | |
16206 Only 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. | |
16222 If 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 | 16295 |
16232 (defun org-on-target-p () | 16296 (defun org-on-target-p () |
16233 (let ((pos (point))) | 16297 (let ((pos (point))) |
16234 (save-excursion | 16298 (save-excursion |
16235 (skip-chars-forward "<") | 16299 (skip-chars-forward "<") |
16241 | 16305 |
16242 (defun org-up-heading-all (arg) | 16306 (defun org-up-heading-all (arg) |
16243 "Move to the heading line of which the present line is a subheading. | 16307 "Move to the heading line of which the present line is a subheading. |
16244 This function considers both visible and invisible heading lines. | 16308 This function considers both visible and invisible heading lines. |
16245 With argument, move up ARG levels." | 16309 With argument, move up ARG levels." |
16246 (if org-noutline-p | 16310 (if (fboundp 'outline-up-heading-all) |
16247 (if (fboundp 'outline-up-heading-all) | 16311 (outline-up-heading-all arg) ; emacs 21 version of outline.el |
16248 (outline-up-heading-all arg) ; emacs 21 version of outline.el | 16312 (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 | 16313 |
16261 (defun org-show-hidden-entry () | 16314 (defun org-show-hidden-entry () |
16262 "Show an entry where even the heading is hidden." | 16315 "Show an entry where even the heading is hidden." |
16263 (save-excursion | 16316 (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))) | 16317 (org-show-entry))) |
16269 | |
16270 (defun org-check-occur-regexp (regexp) | |
16271 "If REGEXP starts with \"^\", modify it to check for \\r as well. | |
16272 Of 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 | 16318 |
16279 (defun org-flag-heading (flag &optional entry) | 16319 (defun org-flag-heading (flag &optional entry) |
16280 "Flag the current heading. FLAG non-nil means make invisible. | 16320 "Flag the current heading. FLAG non-nil means make invisible. |
16281 When ENTRY is non-nil, show the entire entry." | 16321 When ENTRY is non-nil, show the entire entry." |
16282 (save-excursion | 16322 (save-excursion |
16283 (org-back-to-heading t) | 16323 (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 | 16324 ;; Check if we should show the entire entry |
16288 (if entry | 16325 (if entry |
16289 (progn | 16326 (progn |
16290 (org-show-entry) | 16327 (org-show-entry) |
16291 (save-excursion | 16328 (save-excursion |
16292 (and (outline-next-heading) | 16329 (and (outline-next-heading) |
16293 (org-flag-heading nil)))) | 16330 (org-flag-heading nil)))) |
16294 (outline-flag-region (max 1 (1- (point))) | 16331 (outline-flag-region (max 1 (1- (point))) |
16295 (save-excursion (outline-end-of-heading) (point)) | 16332 (save-excursion (outline-end-of-heading) (point)) |
16296 (if org-noutline-p | 16333 flag)))) |
16297 flag | |
16298 (if flag ?\r ?\n)))))) | |
16299 | 16334 |
16300 (defun org-end-of-subtree (&optional invisible-OK) | 16335 (defun org-end-of-subtree (&optional invisible-OK) |
16301 ;; This is an exact copy of the original function, but it uses | 16336 ;; This is an exact copy of the original function, but it uses |
16302 ;; `org-back-to-heading', to make it work also in invisible | 16337 ;; `org-back-to-heading', to make it work also in invisible |
16303 ;; trees. And is uses an invisible-OK argument. | 16338 ;; trees. And is uses an invisible-OK argument. |
16322 "Show everything after this heading at deeper levels." | 16357 "Show everything after this heading at deeper levels." |
16323 (outline-flag-region | 16358 (outline-flag-region |
16324 (point) | 16359 (point) |
16325 (save-excursion | 16360 (save-excursion |
16326 (outline-end-of-subtree) (outline-next-heading) (point)) | 16361 (outline-end-of-subtree) (outline-next-heading) (point)) |
16327 (if org-noutline-p nil ?\n))) | 16362 nil)) |
16328 | 16363 |
16329 (defun org-show-entry () | 16364 (defun org-show-entry () |
16330 "Show the body directly following this heading. | 16365 "Show the body directly following this heading. |
16331 Show the heading too, if it is currently invisible." | 16366 Show the heading too, if it is currently invisible." |
16332 (interactive) | 16367 (interactive) |
16335 (outline-flag-region | 16370 (outline-flag-region |
16336 (max 1 (1- (point))) | 16371 (max 1 (1- (point))) |
16337 (save-excursion | 16372 (save-excursion |
16338 (re-search-forward (concat "[\r\n]\\(" outline-regexp "\\)") nil 'move) | 16373 (re-search-forward (concat "[\r\n]\\(" outline-regexp "\\)") nil 'move) |
16339 (or (match-beginning 1) (point-max))) | 16374 (or (match-beginning 1) (point-max))) |
16340 (if org-noutline-p nil ?\n)))) | 16375 nil))) |
16341 | 16376 |
16342 (defun org-make-options-regexp (kwds) | 16377 (defun org-make-options-regexp (kwds) |
16343 "Make a regular expression for keyword lines." | 16378 "Make a regular expression for keyword lines." |
16344 (concat | 16379 (concat |
16345 (if org-noutline-p "^" "[\n\r]") | 16380 "^" |
16346 "#?[ \t]*\\+\\(" | 16381 "#?[ \t]*\\+\\(" |
16347 (mapconcat 'regexp-quote kwds "\\|") | 16382 (mapconcat 'regexp-quote kwds "\\|") |
16348 "\\):[ \t]*" | 16383 "\\):[ \t]*" |
16349 (if org-noutline-p "\\(.+\\)" "\\([^\n\r]+\\)"))) | 16384 "\\(.+\\)")) |
16350 | 16385 |
16351 ;; Make `bookmark-jump' show the jump location if it was hidden. | 16386 ;; Make `bookmark-jump' show the jump location if it was hidden. |
16352 (eval-after-load "bookmark" | 16387 (eval-after-load "bookmark" |
16353 '(if (boundp 'bookmark-after-jump-hook) | 16388 '(if (boundp 'bookmark-after-jump-hook) |
16354 ;; We can use the hook | 16389 ;; We can use the hook |