comparison lisp/textmodes/org.el @ 69319:7aecee7bf0d9

Move defvars out of eval-when-compile. Use buffer-file-name variable. (org-agenda-file-to-end, org-agenda-file-to-front): Remove unused arg `file'. (org-level-faces): Remove startup dependency. (org-cycle, org-map-tree, org-scan-tags) (org-remember-handler): Don't call `outline-level' directly. (org-mhe-search-all-folders): New option. (org-mhe-get-message-folder-from-index, org-mhe-get-message-folder): Fix indexing search. (org-format-agenda-item): Handle nil TAGS argument. (org-cleaned-string-for-export, org-activate-target-links) (org-make-target-link-regexp): Deal with empty radio target list. (org-tag): New face. (org-get-level-face): New function. (org-set-font-lock-defaults): Simplify setup for headlines. (org-complete): Pass common substring to `display-completion-list'.
author Carsten Dominik <dominik@science.uva.nl>
date Tue, 07 Mar 2006 10:02:12 +0000
parents cdd3f2bbf2f8
children d60237bf3ccc a7364c1a561e
comparison
equal deleted inserted replaced
69318:05d354109b2c 69319:7aecee7bf0d9
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.07 8 ;; Version: 4.08
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
79 ;; excellent reference card made by Philip Rooke. This card can be found 79 ;; excellent reference card made by Philip Rooke. This card can be found
80 ;; in the etc/ directory of Emacs 22. 80 ;; in the etc/ directory of Emacs 22.
81 ;; 81 ;;
82 ;; Changes since version 4.00: 82 ;; Changes since version 4.00:
83 ;; --------------------------- 83 ;; ---------------------------
84 ;; Version 4.08
85 ;;
86 ;;
84 ;; Version 4.07 87 ;; Version 4.07
85 ;; - Bug fixes. 88 ;; - Bug fixes.
86 ;; - Leading stars in headlines can be hidden, so make the outline look 89 ;; - Leading stars in headlines can be hidden, so make the outline look
87 ;; cleaner. 90 ;; cleaner.
88 ;; - Mouse-1 can be used to follow links. 91 ;; - Mouse-1 can be used to follow links.
134 (defvar calc-embedded-open-formula) 137 (defvar calc-embedded-open-formula)
135 (defvar font-lock-unfontify-region-function) 138 (defvar font-lock-unfontify-region-function)
136 139
137 ;;; Customization variables 140 ;;; Customization variables
138 141
139 (defvar org-version "4.07" 142 (defvar org-version "4.08"
140 "The version number of the file org.el.") 143 "The version number of the file org.el.")
141 (defun org-version () 144 (defun org-version ()
142 (interactive) 145 (interactive)
143 (message "Org-mode version %s" org-version)) 146 (message "Org-mode version %s" org-version))
144 147
794 :type 'hook) 797 :type 'hook)
795 798
796 (defcustom org-level-color-stars-only nil 799 (defcustom org-level-color-stars-only nil
797 "Non-nil means fontify only the stars in each headline. 800 "Non-nil means fontify only the stars in each headline.
798 When nil, the entire headline is fontified. 801 When nil, the entire headline is fontified.
799 Changing it requires restart of Emacs to become effective." 802 Changing it requires restart of `font-lock-mode' to become effective."
800 :group 'org-structure 803 :group 'org-structure
801 :type 'boolean) 804 :type 'boolean)
802 805
803 (defcustom org-hide-leading-stars nil 806 (defcustom org-hide-leading-stars nil
804 "Non-nil means, hide the first N-1 stars in a headline. 807 "Non-nil means, hide the first N-1 stars in a headline.
805 This works by using the face `org-hide' for these stars. This 808 This works by using the face `org-hide' for these stars. This
806 face is white for a light background, and black for a dark 809 face is white for a light background, and black for a dark
807 background. You may have to customize the face `org-hide' to 810 background. You may have to customize the face `org-hide' to
808 make this work. 811 make this work.
809 Changing the variable requires restart of Emacs to become effective." 812 Changing it requires restart of `font-lock-mode' to become effective."
810 :group 'org-structure 813 :group 'org-structure
811 :type 'boolean) 814 :type 'boolean)
812 815
813 (defcustom org-odd-levels-only nil 816 (defcustom org-odd-levels-only nil
814 "Non-nil means, skip even levels and only use odd levels for the outline. 817 "Non-nil means, skip even levels and only use odd levels for the outline.
815 This has the effect that two stars are being added/taken away in 818 This has the effect that two stars are being added/taken away in
816 promotion/demotion commands. It also influences how levels are 819 promotion/demotion commands. It also influences how levels are
817 handled by the exporters." 820 handled by the exporters.
821 Changing it requires restart of `font-lock-mode' to become effective
822 for fontification."
818 :group 'org-structure 823 :group 'org-structure
819 :type 'boolean) 824 :type 'boolean)
820 825
821 (defcustom org-adapt-indentation t 826 (defcustom org-adapt-indentation t
822 "Non-nil means, adapt indentation when promoting and demoting. 827 "Non-nil means, adapt indentation when promoting and demoting.
1155 (const :tag "Visit with Emacs" emacs) 1160 (const :tag "Visit with Emacs" emacs)
1156 (const :tag "Use system default" default) 1161 (const :tag "Use system default" default)
1157 (string :tag "Command") 1162 (string :tag "Command")
1158 (sexp :tag "Lisp form"))))) 1163 (sexp :tag "Lisp form")))))
1159 1164
1165 (defcustom org-mhe-search-all-folders nil
1166 "Non-nil means, that the search for the mh-message will be extended to
1167 all folders if the message cannot be found in the folder given in the link.
1168 Searching all folders is very effective with one of the search engines
1169 supported by MH-E, but will be slow with pick."
1170 :group 'org-link
1171 :type 'boolean)
1172
1160 (defgroup org-remember nil 1173 (defgroup org-remember nil
1161 "Options concerning interaction with remember.el." 1174 "Options concerning interaction with remember.el."
1162 :tag "Org Remember" 1175 :tag "Org Remember"
1163 :group 'org) 1176 :group 'org)
1164 1177
1853 (((class color) (background dark)) (:foreground "Cyan")) 1866 (((class color) (background dark)) (:foreground "Cyan"))
1854 (t (:bold t))) 1867 (t (:bold t)))
1855 "Face for links." 1868 "Face for links."
1856 :group 'org-faces) 1869 :group 'org-faces)
1857 1870
1871 (defface org-tag
1872 '((((type tty) (class color)) (:foreground "cyan" :weight bold))
1873 (((class color) (background light)) (:foreground "Purple" :weight bold))
1874 (((class color) (background dark)) (:foreground "Cyan" :weight bold))
1875 (t (:bold t)))
1876 "Face for links."
1877 :group 'org-faces)
1878
1858 (defface org-done ;; font-lock-type-face 1879 (defface org-done ;; font-lock-type-face
1859 '((((type tty) (class color)) (:foreground "green")) 1880 '((((type tty) (class color)) (:foreground "green"))
1860 (((class color) (background light)) (:foreground "ForestGreen" :bold t)) 1881 (((class color) (background light)) (:foreground "ForestGreen" :bold t))
1861 (((class color) (background dark)) (:foreground "PaleGreen" :bold t)) 1882 (((class color) (background dark)) (:foreground "PaleGreen" :bold t))
1862 (t (:bold t :underline t))) 1883 (t (:bold t :underline t)))
1877 (((class color) (background dark)) (:foreground "LightGoldenrod")) 1898 (((class color) (background dark)) (:foreground "LightGoldenrod"))
1878 (t (:bold t :italic t))) 1899 (t (:bold t :italic t)))
1879 "Face used for time grids." 1900 "Face used for time grids."
1880 :group 'org-faces) 1901 :group 'org-faces)
1881 1902
1882 (defvar org-level-faces nil) 1903 (defvar org-level-faces
1883 1904 '(org-level-1 org-level-2 org-level-3 org-level-4
1884 (when (not org-level-faces) 1905 org-level-5 org-level-6 org-level-7 org-level-8
1885 (setq org-level-faces 1906 ))
1886 '(
1887 org-level-1
1888 org-level-2
1889 org-level-3
1890 org-level-4
1891 org-level-5
1892 org-level-6
1893 org-level-7
1894 org-level-8
1895 ))
1896 (when org-odd-levels-only
1897 (setq org-level-faces (apply 'append (mapcar (lambda (x) (list x x))
1898 org-level-faces)))
1899 (setq org-level-faces (append (cdr org-level-faces) (list 'org-level-1)))))
1900
1901 (defvar org-n-levels (length org-level-faces)) 1907 (defvar org-n-levels (length org-level-faces))
1902 1908
1903 (defun org-set-regexps-and-options () 1909 (defun org-set-regexps-and-options ()
1904 "Precompute regular expressions for current buffer." 1910 "Precompute regular expressions for current buffer."
1905 (when (eq major-mode 'org-mode) 1911 (when (eq major-mode 'org-mode)
1983 (concat "\\<" org-scheduled-string " *<\\([^>]+\\)>")) 1989 (concat "\\<" org-scheduled-string " *<\\([^>]+\\)>"))
1984 (org-set-font-lock-defaults))) 1990 (org-set-font-lock-defaults)))
1985 1991
1986 ;; Tell the compiler about dynamically scoped variables, 1992 ;; Tell the compiler about dynamically scoped variables,
1987 ;; and variables from other packages 1993 ;; and variables from other packages
1988 (eval-when-compile 1994 (defvar zmacs-regions)
1989 (defvar zmacs-regions) 1995 (defvar original-date)
1990 (defvar original-date) 1996 (defvar org-transient-mark-mode)
1991 (defvar org-transient-mark-mode) 1997 (defvar org-old-auto-fill-inhibit-regexp)
1992 (defvar org-old-auto-fill-inhibit-regexp) 1998 (defvar orgtbl-mode-menu)
1993 (defvar orgtbl-mode-menu) 1999 (defvar org-html-entities)
1994 (defvar org-html-entities) 2000 (defvar org-goto-start-pos)
1995 (defvar org-goto-start-pos) 2001 (defvar org-cursor-color)
1996 (defvar org-cursor-color) 2002 (defvar org-time-was-given)
1997 (defvar org-time-was-given) 2003 (defvar org-ts-what)
1998 (defvar org-ts-what) 2004 (defvar mark-active)
1999 (defvar mark-active) 2005 (defvar timecnt)
2000 (defvar timecnt) 2006 (defvar levels-open)
2001 (defvar levels-open) 2007 (defvar title)
2002 (defvar title) 2008 (defvar author)
2003 (defvar author) 2009 (defvar email)
2004 (defvar email) 2010 (defvar text)
2005 (defvar text) 2011 (defvar entry)
2006 (defvar entry) 2012 (defvar date)
2007 (defvar date) 2013 (defvar language)
2008 (defvar language) 2014 (defvar options)
2009 (defvar options) 2015 (defvar ans1)
2010 (defvar ans1) 2016 (defvar ans2)
2011 (defvar ans2) 2017 (defvar starting-day)
2012 (defvar starting-day) 2018 (defvar include-all-loc)
2013 (defvar include-all-loc) 2019 (defvar vm-message-pointer)
2014 (defvar vm-message-pointer) 2020 (defvar vm-folder-directory)
2015 (defvar vm-folder-directory) 2021 (defvar wl-summary-buffer-elmo-folder)
2016 (defvar wl-summary-buffer-elmo-folder) 2022 (defvar wl-summary-buffer-folder-name)
2017 (defvar wl-summary-buffer-folder-name) 2023 (defvar gnus-group-name)
2018 (defvar gnus-group-name) 2024 (defvar gnus-article-current)
2019 (defvar gnus-article-current) 2025 (defvar w3m-current-url)
2020 (defvar w3m-current-url) 2026 (defvar mh-progs)
2021 (defvar mh-progs) 2027 (defvar mh-current-folder)
2022 (defvar mh-current-folder) 2028 (defvar mh-show-folder-buffer)
2023 (defvar mh-show-folder-buffer) 2029 (defvar mh-index-folder)
2024 (defvar mh-index-folder) 2030 (defvar mh-searcher)
2025 (defvar org-selected-point) 2031 (defvar org-selected-point)
2026 (defvar calendar-mode-map) 2032 (defvar calendar-mode-map)
2027 (defvar remember-save-after-remembering) 2033 (defvar remember-save-after-remembering)
2028 (defvar remember-data-file) 2034 (defvar remember-data-file)
2029 (defvar last-arg)) 2035 (defvar last-arg)
2030 2036
2031 ;;; Define the mode 2037 ;;; Define the mode
2032 2038
2033 (defvar org-mode-map (copy-keymap outline-mode-map) 2039 (defvar org-mode-map (copy-keymap outline-mode-map)
2034 "Keymap for Org-mode.") 2040 "Keymap for Org-mode.")
2214 (defvar org-radio-target-regexp "<<<\\([^<>\n\r]+\\)>>>" 2220 (defvar org-radio-target-regexp "<<<\\([^<>\n\r]+\\)>>>"
2215 "Regular expression matching a link target.") 2221 "Regular expression matching a link target.")
2216 2222
2217 (defun org-activate-target-links (limit) 2223 (defun org-activate-target-links (limit)
2218 "Run through the buffer and add overlays to target matches." 2224 "Run through the buffer and add overlays to target matches."
2219 (when org-radio-targets 2225 (when (and org-radio-targets org-target-link-regexp)
2220 (let ((case-fold-search t)) 2226 (let ((case-fold-search t))
2221 (if (re-search-forward org-target-link-regexp limit t) 2227 (if (re-search-forward org-target-link-regexp limit t)
2222 (progn 2228 (progn
2223 (add-text-properties (match-beginning 0) (match-end 0) 2229 (add-text-properties (match-beginning 0) (match-end 0)
2224 (list 'mouse-face 'highlight 2230 (list 'mouse-face 'highlight
2251 2257
2252 (defun org-make-target-link-regexp (targets) 2258 (defun org-make-target-link-regexp (targets)
2253 "Make regular expression matching all strings in TARGETS. 2259 "Make regular expression matching all strings in TARGETS.
2254 The regular expression finds the targets also if there is a line break 2260 The regular expression finds the targets also if there is a line break
2255 between words." 2261 between words."
2256 (concat 2262 (and targets
2257 "\\<\\(" 2263 (concat
2258 (mapconcat 2264 "\\<\\("
2259 (lambda (x) 2265 (mapconcat
2260 (while (string-match " +" x) 2266 (lambda (x)
2261 (setq x (replace-match "\\s-+" t t x))) 2267 (while (string-match " +" x)
2262 x) 2268 (setq x (replace-match "\\s-+" t t x)))
2263 targets 2269 x)
2264 "\\|") 2270 targets
2265 "\\)\\>")) 2271 "\\|")
2272 "\\)\\>")))
2266 2273
2267 (defvar org-camel-regexp "\\*?\\<[A-Z]+[a-z]+[A-Z][a-zA-Z]*\\>" 2274 (defvar org-camel-regexp "\\*?\\<[A-Z]+[a-z]+[A-Z][a-zA-Z]*\\>"
2268 "Matches CamelCase words, possibly with a star before it.") 2275 "Matches CamelCase words, possibly with a star before it.")
2269 2276
2270 (defun org-activate-camels (limit) 2277 (defun org-activate-camels (limit)
2300 (defvar org-font-lock-keywords nil) 2307 (defvar org-font-lock-keywords nil)
2301 2308
2302 (defun org-set-font-lock-defaults () 2309 (defun org-set-font-lock-defaults ()
2303 (let ((org-font-lock-extra-keywords 2310 (let ((org-font-lock-extra-keywords
2304 (list 2311 (list
2312 '("^\\(\\**\\)\\(\\*\\)\\(.*\\)" (1 (org-get-level-face 1))
2313 (2 (org-get-level-face 2)) (3 (org-get-level-face 3)))
2305 '(org-activate-links (0 'org-link t)) 2314 '(org-activate-links (0 'org-link t))
2306 '(org-activate-links2 (0 'org-link t)) 2315 '(org-activate-links2 (0 'org-link t))
2307 '(org-activate-target-links (0 'org-link t)) 2316 '(org-activate-target-links (0 'org-link t))
2308 '(org-activate-dates (0 'org-link t)) 2317 '(org-activate-dates (0 'org-link t))
2309 '(org-activate-camels (0 'org-link t)) 2318 '(org-activate-camels (0 'org-link t))
2310 '(org-activate-tags (1 'org-link t)) 2319 '(org-activate-tags (1 'org-tag t))
2311 (list (concat "^\\*+[ \t]*" org-not-done-regexp) 2320 (list (concat "^\\*+[ \t]*" org-not-done-regexp)
2312 '(1 'org-warning t)) 2321 '(1 'org-warning t))
2313 (list (concat "\\[#[A-Z]\\]") '(0 'org-special-keyword t)) 2322 (list (concat "\\[#[A-Z]\\]") '(0 'org-special-keyword t))
2314 (list (concat "\\<" org-deadline-string) '(0 'org-special-keyword t)) 2323 (list (concat "\\<" org-deadline-string) '(0 'org-special-keyword t))
2315 (list (concat "\\<" org-scheduled-string) '(0 'org-special-keyword t)) 2324 (list (concat "\\<" org-scheduled-string) '(0 'org-special-keyword t))
2332 '("^[ \t]*\\(\\(|\\|\\+-[-+]\\).*\\S-\\)" 2341 '("^[ \t]*\\(\\(|\\|\\+-[-+]\\).*\\S-\\)"
2333 (1 'org-table t)) 2342 (1 'org-table t))
2334 '("^[ \t]*\\(:.*\\)" (1 'org-table t)) 2343 '("^[ \t]*\\(:.*\\)" (1 'org-table t))
2335 '("| *\\(:?=[^|\n]*\\)" (1 'org-formula t)) 2344 '("| *\\(:?=[^|\n]*\\)" (1 'org-formula t))
2336 '("^[ \t]*| *\\([#!$*_^]\\) *|" (1 'org-formula t)) 2345 '("^[ \t]*| *\\([#!$*_^]\\) *|" (1 'org-formula t))
2337 )) 2346 )))
2338 (exp 2347
2339 ;; The font-lock expression for headlines is complicated. It depends
2340 ;; on two user options, and it needs to determine the level in
2341 ;; order to compute the level.
2342 (cond
2343 ((and org-level-color-stars-only (not org-hide-leading-stars))
2344 '("^\\(\\*+\\).*" 1 (nth (% (- (match-end 1) (match-beginning 1) 1) org-n-levels) org-level-faces) nil t))
2345 ((and (not org-level-color-stars-only) org-hide-leading-stars)
2346 '("^\\(\\**\\)\\(\\*.*\\)" (1 'org-hide) (2 (nth (% (- (match-end 1) (match-beginning 1)) org-n-levels) org-level-faces) nil t)))
2347 ((and org-level-color-stars-only org-hide-leading-stars)
2348 '("^\\(\\**\\)\\(\\*\\).*" (1 'org-hide) (2 (nth (% (- (match-end 1) (match-beginning 1)) org-n-levels) org-level-faces) nil t)))
2349 (t
2350 '("^\\(\\*+\\).*" 0 (nth (% (- (match-end 1) (match-beginning 1) 1) org-n-levels) org-level-faces) nil t)))))
2351
2352 ;; Now set the full font-lock-keywords 2348 ;; Now set the full font-lock-keywords
2353 (set (make-local-variable 'org-font-lock-keywords) 2349 (set (make-local-variable 'org-font-lock-keywords)
2354 (append 2350 org-font-lock-extra-keywords)
2355 (if org-xemacs-p (list exp) (list (cons 'eval (list 'quote exp))))
2356 org-font-lock-extra-keywords))
2357 (set (make-local-variable 'font-lock-defaults) 2351 (set (make-local-variable 'font-lock-defaults)
2358 '(org-font-lock-keywords t nil nil backward-paragraph)) 2352 '(org-font-lock-keywords t nil nil backward-paragraph))
2359 (kill-local-variable 'font-lock-keywords) nil)) 2353 (kill-local-variable 'font-lock-keywords) nil))
2354
2355 (defvar org-m nil)
2356 (defvar org-l nil)
2357 (defvar org-f nil)
2358 (defun org-get-level-face (n)
2359 "Get the right face for match N in font-lock matching of healdines."
2360 (setq org-l (- (match-end 2) (match-beginning 1)))
2361 (if org-odd-levels-only (setq org-l (1+ (/ org-l 2))))
2362 (setq org-f (nth (1- (% org-l org-n-levels)) org-level-faces))
2363 (cond
2364 ((eq n 1) (if org-hide-leading-stars 'org-hide org-f))
2365 ((eq n 2) org-f)
2366 (t (if org-level-color-stars-only nil org-f))))
2360 2367
2361 (defun org-unfontify-region (beg end &optional maybe_loudly) 2368 (defun org-unfontify-region (beg end &optional maybe_loudly)
2362 "Remove fontification and activation overlays from links." 2369 "Remove fontification and activation overlays from links."
2363 (font-lock-default-unfontify-region beg end) 2370 (font-lock-default-unfontify-region beg end)
2364 (let* ((buffer-undo-list t) 2371 (let* ((buffer-undo-list t)
2461 ((integerp arg) 2468 ((integerp arg)
2462 ;; Show-subtree, ARG levels up from here. 2469 ;; Show-subtree, ARG levels up from here.
2463 (save-excursion 2470 (save-excursion
2464 (org-back-to-heading) 2471 (org-back-to-heading)
2465 (outline-up-heading (if (< arg 0) (- arg) 2472 (outline-up-heading (if (< arg 0) (- arg)
2466 (- (outline-level) arg))) 2473 (- (funcall outline-level) arg)))
2467 (org-show-subtree))) 2474 (org-show-subtree)))
2468 2475
2469 ((save-excursion (beginning-of-line 1) (looking-at outline-regexp)) 2476 ((save-excursion (beginning-of-line 1) (looking-at outline-regexp))
2470 ;; At a heading: rotate between three different views 2477 ;; At a heading: rotate between three different views
2471 (org-back-to-heading) 2478 (org-back-to-heading)
2818 (org-fixup-indentation "^ " (if (> diff 1) " " " ") "^\\S-")))) 2825 (org-fixup-indentation "^ " (if (> diff 1) " " " ") "^\\S-"))))
2819 2826
2820 (defun org-map-tree (fun) 2827 (defun org-map-tree (fun)
2821 "Call FUN for every heading underneath the current one." 2828 "Call FUN for every heading underneath the current one."
2822 (org-back-to-heading) 2829 (org-back-to-heading)
2823 (let ((level (outline-level))) 2830 (let ((level (funcall outline-level)))
2824 (save-excursion 2831 (save-excursion
2825 (funcall fun) 2832 (funcall fun)
2826 (while (and (progn 2833 (while (and (progn
2827 (outline-next-heading) 2834 (outline-next-heading)
2828 (> (funcall outline-level) level)) 2835 (> (funcall outline-level) level))
3299 (this-buffer (current-buffer)) 3306 (this-buffer (current-buffer))
3300 file heading buffer level newfile-p) 3307 file heading buffer level newfile-p)
3301 (if (string-match "\\(.*\\)::\\(.*\\)" org-archive-location) 3308 (if (string-match "\\(.*\\)::\\(.*\\)" org-archive-location)
3302 (progn 3309 (progn
3303 (setq file (format (match-string 1 org-archive-location) 3310 (setq file (format (match-string 1 org-archive-location)
3304 (file-name-nondirectory (buffer-file-name))) 3311 (file-name-nondirectory buffer-file-name))
3305 heading (match-string 2 org-archive-location))) 3312 heading (match-string 2 org-archive-location)))
3306 (error "Invalid `org-archive-location'")) 3313 (error "Invalid `org-archive-location'"))
3307 (if (> (length file) 0) 3314 (if (> (length file) 0)
3308 (setq newfile-p (not (file-exists-p file)) 3315 (setq newfile-p (not (file-exists-p file))
3309 buffer (find-file-noselect file)) 3316 buffer (find-file-noselect file))
3466 "Press \\[org-complete] again to insert example settings")))) 3473 "Press \\[org-complete] again to insert example settings"))))
3467 (t 3474 (t
3468 (message "Making completion list...") 3475 (message "Making completion list...")
3469 (let ((list (sort (all-completions pattern table) 'string<))) 3476 (let ((list (sort (all-completions pattern table) 'string<)))
3470 (with-output-to-temp-buffer "*Completions*" 3477 (with-output-to-temp-buffer "*Completions*"
3471 (display-completion-list list))) 3478 (condition-case nil
3479 ;; Protection needed for XEmacs and emacs 21
3480 (display-completion-list list pattern)
3481 (error (display-completion-list list)))))
3472 (message "Making completion list...%s" "done")))))) 3482 (message "Making completion list...%s" "done"))))))
3473 3483
3474 ;;; Comments, TODO and DEADLINE 3484 ;;; Comments, TODO and DEADLINE
3475 3485
3476 (defun org-toggle-comment () 3486 (defun org-toggle-comment ()
4489 If the current buffer is in Org-mode and visiting a file, you can also 4499 If the current buffer is in Org-mode and visiting a file, you can also
4490 first press `1' to indicate that the agenda should be temporarily (until the 4500 first press `1' to indicate that the agenda should be temporarily (until the
4491 next use of \\[org-agenda]) restricted to the current file." 4501 next use of \\[org-agenda]) restricted to the current file."
4492 (interactive "P") 4502 (interactive "P")
4493 (catch 'exit 4503 (catch 'exit
4494 (let ((restrict-ok (and (buffer-file-name) (eq major-mode 'org-mode))) 4504 (let ((restrict-ok (and buffer-file-name (eq major-mode 'org-mode)))
4495 (custom org-agenda-custom-commands) 4505 (custom org-agenda-custom-commands)
4496 c entry key type string) 4506 c entry key type string)
4497 (put 'org-agenda-files 'org-restrict nil) 4507 (put 'org-agenda-files 'org-restrict nil)
4498 (save-window-excursion 4508 (save-window-excursion
4499 (delete-other-windows) 4509 (delete-other-windows)
4524 (if restrict-ok ", or [1] to restrict to current file" "")) 4534 (if restrict-ok ", or [1] to restrict to current file" ""))
4525 (setq c (read-char-exclusive)) 4535 (setq c (read-char-exclusive))
4526 (message "") 4536 (message "")
4527 (when (equal c ?1) 4537 (when (equal c ?1)
4528 (if restrict-ok 4538 (if restrict-ok
4529 (put 'org-agenda-files 'org-restrict (list (buffer-file-name))) 4539 (put 'org-agenda-files 'org-restrict (list buffer-file-name))
4530 (error "Cannot restrict agenda to current buffer")) 4540 (error "Cannot restrict agenda to current buffer"))
4531 (message "Press key for agenda command%s" 4541 (message "Press key for agenda command%s"
4532 (if restrict-ok " (restricted to current file)" "")) 4542 (if restrict-ok " (restricted to current file)" ""))
4533 (setq c (read-char-exclusive)) 4543 (setq c (read-char-exclusive))
4534 (message ""))) 4544 (message "")))
4648 (org-compile-prefix-format org-timeline-prefix-format) 4658 (org-compile-prefix-format org-timeline-prefix-format)
4649 (let* ((dopast t) 4659 (let* ((dopast t)
4650 (dotodo include-all) 4660 (dotodo include-all)
4651 (doclosed org-agenda-show-log) 4661 (doclosed org-agenda-show-log)
4652 (org-agenda-keep-modes keep-modes) 4662 (org-agenda-keep-modes keep-modes)
4653 (entry (buffer-file-name)) 4663 (entry buffer-file-name)
4654 (org-agenda-files (list (buffer-file-name))) 4664 (org-agenda-files (list buffer-file-name))
4655 (date (calendar-current-date)) 4665 (date (calendar-current-date))
4656 (win (selected-window)) 4666 (win (selected-window))
4657 (pos1 (point)) 4667 (pos1 (point))
4658 (beg (if (org-region-active-p) (region-beginning) (point-min))) 4668 (beg (if (org-region-active-p) (region-beginning) (point-min)))
4659 (end (if (org-region-active-p) (region-end) (point-max))) 4669 (end (if (org-region-active-p) (region-end) (point-max)))
5176 ;; Hook not avaiable, must use advice to make this work 5186 ;; Hook not avaiable, must use advice to make this work
5177 (defadvice add-to-diary-list (before org-mark-diary-entry activate) 5187 (defadvice add-to-diary-list (before org-mark-diary-entry activate)
5178 "Make the position visible." 5188 "Make the position visible."
5179 (if (and org-disable-agenda-to-diary ;; called from org-agenda 5189 (if (and org-disable-agenda-to-diary ;; called from org-agenda
5180 (stringp string) 5190 (stringp string)
5181 (buffer-file-name)) 5191 buffer-file-name)
5182 (setq string (org-modify-diary-entry-string string)))))) 5192 (setq string (org-modify-diary-entry-string string))))))
5183 5193
5184 (defun org-modify-diary-entry-string (string) 5194 (defun org-modify-diary-entry-string (string)
5185 "Add text properties to string, allowing org-mode to act on it." 5195 "Add text properties to string, allowing org-mode to act on it."
5186 (add-text-properties 5196 (add-text-properties
5188 (list 'mouse-face 'highlight 5198 (list 'mouse-face 'highlight
5189 'keymap org-agenda-keymap 5199 'keymap org-agenda-keymap
5190 'help-echo 5200 'help-echo
5191 (format 5201 (format
5192 "mouse-2 or RET jump to diary file %s" 5202 "mouse-2 or RET jump to diary file %s"
5193 (abbreviate-file-name (buffer-file-name))) 5203 (abbreviate-file-name buffer-file-name))
5194 'org-agenda-diary-link t 5204 'org-agenda-diary-link t
5195 'org-marker (org-agenda-new-marker (point-at-bol))) 5205 'org-marker (org-agenda-new-marker (point-at-bol)))
5196 string) 5206 string)
5197 string) 5207 string)
5198 5208
5210 "Cycle through the files in `org-agenda-files'. 5220 "Cycle through the files in `org-agenda-files'.
5211 If the current buffer visits an agenda file, find the next one in the list. 5221 If the current buffer visits an agenda file, find the next one in the list.
5212 If the current buffer does not, find the first agenda file." 5222 If the current buffer does not, find the first agenda file."
5213 (interactive) 5223 (interactive)
5214 (let ((files (append org-agenda-files (list (car org-agenda-files)))) 5224 (let ((files (append org-agenda-files (list (car org-agenda-files))))
5215 (tcf (if (buffer-file-name) (file-truename (buffer-file-name)))) 5225 (tcf (if buffer-file-name (file-truename buffer-file-name)))
5216 file) 5226 file)
5217 (unless files (error "No agenda files")) 5227 (unless files (error "No agenda files"))
5218 (catch 'exit 5228 (catch 'exit
5219 (while (setq file (pop files)) 5229 (while (setq file (pop files))
5220 (if (equal (file-truename file) tcf) 5230 (if (equal (file-truename file) tcf)
5221 (when (car files) 5231 (when (car files)
5222 (find-file (car files)) 5232 (find-file (car files))
5223 (throw 'exit t)))) 5233 (throw 'exit t))))
5224 (find-file (car org-agenda-files))))) 5234 (find-file (car org-agenda-files)))))
5225 5235
5226 (defun org-agenda-file-to-end (&optional file) 5236 (defun org-agenda-file-to-end ()
5227 "Move/add the current file to the end of the agenda file list. 5237 "Move/add the current file to the end of the agenda file list.
5228 If the file is not present in the list, it is appended to the list. If it is 5238 If the file is not present in the list, it is appended to the list. If it is
5229 present, it is moved there." 5239 present, it is moved there."
5230 (interactive) 5240 (interactive)
5231 (org-agenda-file-to-front 'to-end file)) 5241 (org-agenda-file-to-front 'to-end))
5232 5242
5233 (defun org-agenda-file-to-front (&optional to-end file) 5243 (defun org-agenda-file-to-front (&optional to-end)
5234 "Move/add the current file to the top of the agenda file list. 5244 "Move/add the current file to the top of the agenda file list.
5235 If the file is not present in the list, it is added to the front. If it is 5245 If the file is not present in the list, it is added to the front. If it is
5236 present, it is moved there. With optional argument TO-END, add/move to the 5246 present, it is moved there. With optional argument TO-END, add/move to the
5237 end of the list." 5247 end of the list."
5238 (interactive "P") 5248 (interactive "P")
5239 (let ((file-alist (mapcar (lambda (x) 5249 (let ((file-alist (mapcar (lambda (x)
5240 (cons (file-truename x) x)) 5250 (cons (file-truename x) x))
5241 org-agenda-files)) 5251 org-agenda-files))
5242 (ctf (file-truename (buffer-file-name))) 5252 (ctf (file-truename buffer-file-name))
5243 x had) 5253 x had)
5244 (setq x (assoc ctf file-alist) had x) 5254 (setq x (assoc ctf file-alist) had x)
5245 5255
5246 (if (not x) (setq x (cons ctf (abbreviate-file-name (buffer-file-name))))) 5256 (if (not x) (setq x (cons ctf (abbreviate-file-name buffer-file-name))))
5247 (if to-end 5257 (if to-end
5248 (setq file-alist (append (delq x file-alist) (list x))) 5258 (setq file-alist (append (delq x file-alist) (list x)))
5249 (setq file-alist (cons x (delq x file-alist)))) 5259 (setq file-alist (cons x (delq x file-alist))))
5250 (setq org-agenda-files (mapcar 'cdr file-alist)) 5260 (setq org-agenda-files (mapcar 'cdr file-alist))
5251 (let ((org-mode-hook nil) (default-major-mode 'fundamental-mode)) 5261 (let ((org-mode-hook nil) (default-major-mode 'fundamental-mode))
5257 (defun org-remove-file (&optional file) 5267 (defun org-remove-file (&optional file)
5258 "Remove current file from the list of files in variable `org-agenda-files'. 5268 "Remove current file from the list of files in variable `org-agenda-files'.
5259 These are the files which are being checked for agenda entries. 5269 These are the files which are being checked for agenda entries.
5260 Optional argument FILE means, use this file instead of the current." 5270 Optional argument FILE means, use this file instead of the current."
5261 (interactive) 5271 (interactive)
5262 (let* ((file (or file (buffer-file-name))) 5272 (let* ((file (or file buffer-file-name))
5263 (true-file (file-truename file)) 5273 (true-file (file-truename file))
5264 (afile (abbreviate-file-name file)) 5274 (afile (abbreviate-file-name file))
5265 (files (delq nil (mapcar 5275 (files (delq nil (mapcar
5266 (lambda (x) 5276 (lambda (x)
5267 (if (equal true-file 5277 (if (equal true-file
5381 "Get the category applying to position POS." 5391 "Get the category applying to position POS."
5382 (if (not org-category-table) 5392 (if (not org-category-table)
5383 (cond 5393 (cond
5384 ((null org-category) 5394 ((null org-category)
5385 (setq org-category 5395 (setq org-category
5386 (if (buffer-file-name) 5396 (if buffer-file-name
5387 (file-name-sans-extension 5397 (file-name-sans-extension
5388 (file-name-nondirectory (buffer-file-name))) 5398 (file-name-nondirectory buffer-file-name))
5389 "???"))) 5399 "???")))
5390 ((symbolp org-category) (symbol-name org-category)) 5400 ((symbolp org-category) (symbol-name org-category))
5391 (t org-category)) 5401 (t org-category))
5392 (let ((tbl org-category-table) 5402 (let ((tbl org-category-table)
5393 (pos (or pos (point)))) 5403 (pos (or pos (point))))
5480 'done-face 'org-done 5490 'done-face 'org-done
5481 'mouse-face 'highlight 5491 'mouse-face 'highlight
5482 'keymap org-agenda-keymap 5492 'keymap org-agenda-keymap
5483 'help-echo 5493 'help-echo
5484 (format "mouse-2 or RET jump to org file %s" 5494 (format "mouse-2 or RET jump to org file %s"
5485 (abbreviate-file-name (buffer-file-name))))) 5495 (abbreviate-file-name buffer-file-name))))
5486 (regexp (concat "[\n\r]\\*+ *\\(" 5496 (regexp (concat "[\n\r]\\*+ *\\("
5487 (if org-select-this-todo-keyword 5497 (if org-select-this-todo-keyword
5488 (concat "\\<\\(" org-select-this-todo-keyword 5498 (concat "\\<\\(" org-select-this-todo-keyword
5489 "\\)\\>") 5499 "\\)\\>")
5490 org-not-done-regexp) 5500 org-not-done-regexp)
5522 (let* ((props (list 'face nil 5532 (let* ((props (list 'face nil
5523 'mouse-face 'highlight 5533 'mouse-face 'highlight
5524 'keymap org-agenda-keymap 5534 'keymap org-agenda-keymap
5525 'help-echo 5535 'help-echo
5526 (format "mouse-2 or RET jump to org file %s" 5536 (format "mouse-2 or RET jump to org file %s"
5527 (abbreviate-file-name (buffer-file-name))))) 5537 (abbreviate-file-name buffer-file-name))))
5528 (regexp (regexp-quote 5538 (regexp (regexp-quote
5529 (substring 5539 (substring
5530 (format-time-string 5540 (format-time-string
5531 (car org-time-stamp-formats) 5541 (car org-time-stamp-formats)
5532 (apply 'encode-time ; DATE bound by calendar 5542 (apply 'encode-time ; DATE bound by calendar
5599 "Return the logged TODO entries for agenda display." 5609 "Return the logged TODO entries for agenda display."
5600 (let* ((props (list 'mouse-face 'highlight 5610 (let* ((props (list 'mouse-face 'highlight
5601 'keymap org-agenda-keymap 5611 'keymap org-agenda-keymap
5602 'help-echo 5612 'help-echo
5603 (format "mouse-2 or RET jump to org file %s" 5613 (format "mouse-2 or RET jump to org file %s"
5604 (abbreviate-file-name (buffer-file-name))))) 5614 (abbreviate-file-name buffer-file-name))))
5605 (regexp (concat 5615 (regexp (concat
5606 "\\<" org-closed-string " *\\[" 5616 "\\<" org-closed-string " *\\["
5607 (regexp-quote 5617 (regexp-quote
5608 (substring 5618 (substring
5609 (format-time-string 5619 (format-time-string
5655 (let* ((wdays org-deadline-warning-days) 5665 (let* ((wdays org-deadline-warning-days)
5656 (props (list 'mouse-face 'highlight 5666 (props (list 'mouse-face 'highlight
5657 'keymap org-agenda-keymap 5667 'keymap org-agenda-keymap
5658 'help-echo 5668 'help-echo
5659 (format "mouse-2 or RET jump to org file %s" 5669 (format "mouse-2 or RET jump to org file %s"
5660 (abbreviate-file-name (buffer-file-name))))) 5670 (abbreviate-file-name buffer-file-name))))
5661 (regexp org-deadline-time-regexp) 5671 (regexp org-deadline-time-regexp)
5662 (todayp (equal date (calendar-current-date))) ; DATE bound by calendar 5672 (todayp (equal date (calendar-current-date))) ; DATE bound by calendar
5663 (d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar 5673 (d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar
5664 d2 diff pos pos1 category tags 5674 d2 diff pos pos1 category tags
5665 ee txt head) 5675 ee txt head)
5717 'done-face 'org-done 5727 'done-face 'org-done
5718 'mouse-face 'highlight 5728 'mouse-face 'highlight
5719 'keymap org-agenda-keymap 5729 'keymap org-agenda-keymap
5720 'help-echo 5730 'help-echo
5721 (format "mouse-2 or RET jump to org file %s" 5731 (format "mouse-2 or RET jump to org file %s"
5722 (abbreviate-file-name (buffer-file-name))))) 5732 (abbreviate-file-name buffer-file-name))))
5723 (regexp org-scheduled-time-regexp) 5733 (regexp org-scheduled-time-regexp)
5724 (todayp (equal date (calendar-current-date))) ; DATE bound by calendar 5734 (todayp (equal date (calendar-current-date))) ; DATE bound by calendar
5725 (d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar 5735 (d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar
5726 d2 diff pos pos1 category tags 5736 d2 diff pos pos1 category tags
5727 ee txt head) 5737 ee txt head)
5766 (let* ((props (list 'face nil 5776 (let* ((props (list 'face nil
5767 'mouse-face 'highlight 5777 'mouse-face 'highlight
5768 'keymap org-agenda-keymap 5778 'keymap org-agenda-keymap
5769 'help-echo 5779 'help-echo
5770 (format "mouse-2 or RET jump to org file %s" 5780 (format "mouse-2 or RET jump to org file %s"
5771 (abbreviate-file-name (buffer-file-name))))) 5781 (abbreviate-file-name buffer-file-name))))
5772 (regexp org-tr-regexp) 5782 (regexp org-tr-regexp)
5773 (d0 (calendar-absolute-from-gregorian date)) 5783 (d0 (calendar-absolute-from-gregorian date))
5774 marker hdmarker ee txt d1 d2 s1 s2 timestr category tags) 5784 marker hdmarker ee txt d1 d2 s1 s2 timestr category tags)
5775 (goto-char (point-min)) 5785 (goto-char (point-min))
5776 (while (re-search-forward regexp nil t) 5786 (while (re-search-forward regexp nil t)
5859 (save-match-data 5869 (save-match-data
5860 ;; Diary entries sometimes have extra whitespace at the beginning 5870 ;; Diary entries sometimes have extra whitespace at the beginning
5861 (if (string-match "^ +" txt) (setq txt (replace-match "" nil nil txt))) 5871 (if (string-match "^ +" txt) (setq txt (replace-match "" nil nil txt)))
5862 (let* ((category (or category 5872 (let* ((category (or category
5863 org-category 5873 org-category
5864 (if (buffer-file-name) 5874 (if buffer-file-name
5865 (file-name-sans-extension 5875 (file-name-sans-extension
5866 (file-name-nondirectory (buffer-file-name))) 5876 (file-name-nondirectory buffer-file-name))
5867 ""))) 5877 "")))
5868 (tag (or (nth (1- (length tags)) tags) "")) 5878 (tag (or (nth (1- (or (length tags) 0)) tags) ""))
5869 time ;; needed for the eval of the prefix format 5879 time ;; needed for the eval of the prefix format
5870 (ts (if dotime (concat (if (stringp dotime) dotime "") txt))) 5880 (ts (if dotime (concat (if (stringp dotime) dotime "") txt)))
5871 (time-of-day (and dotime (org-get-time-of-day ts))) 5881 (time-of-day (and dotime (org-get-time-of-day ts)))
5872 stamp plain s0 s1 s2 rtn) 5882 stamp plain s0 s1 s2 rtn)
5873 (when (and dotime time-of-day org-prefix-has-time) 5883 (when (and dotime time-of-day org-prefix-has-time)
6493 'undone-face nil 6503 'undone-face nil
6494 'mouse-face 'highlight 6504 'mouse-face 'highlight
6495 'keymap org-agenda-keymap 6505 'keymap org-agenda-keymap
6496 'help-echo 6506 'help-echo
6497 (format "mouse-2 or RET jump to org file %s" 6507 (format "mouse-2 or RET jump to org file %s"
6498 (abbreviate-file-name (buffer-file-name))))) 6508 (abbreviate-file-name buffer-file-name))))
6499 lspos 6509 lspos
6500 tags tags-list tags-alist (llast 0) rtn level category i txt 6510 tags tags-list tags-alist (llast 0) rtn level category i txt
6501 todo marker) 6511 todo marker)
6502 6512
6503 (save-excursion 6513 (save-excursion
6505 (when (eq action 'sparse-tree) (hide-sublevels 1)) 6515 (when (eq action 'sparse-tree) (hide-sublevels 1))
6506 (while (re-search-forward re nil t) 6516 (while (re-search-forward re nil t)
6507 (setq todo (if (match-end 1) (match-string 2)) 6517 (setq todo (if (match-end 1) (match-string 2))
6508 tags (if (match-end 4) (match-string 4))) 6518 tags (if (match-end 4) (match-string 4)))
6509 (goto-char (setq lspos (1+ (match-beginning 0)))) 6519 (goto-char (setq lspos (1+ (match-beginning 0))))
6510 (setq level (outline-level) 6520 (setq level (funcall outline-level)
6511 category (org-get-category)) 6521 category (org-get-category))
6512 (setq i llast llast level) 6522 (setq i llast llast level)
6513 ;; remove tag lists from same and sublevels 6523 ;; remove tag lists from same and sublevels
6514 (while (>= i level) 6524 (while (>= i level)
6515 (when (setq entry (assoc i tags-alist)) 6525 (when (setq entry (assoc i tags-alist))
7230 7240
7231 (defun org-mhe-get-message-folder-from-index () 7241 (defun org-mhe-get-message-folder-from-index ()
7232 "Returns the name of the message folder in a index folder buffer." 7242 "Returns the name of the message folder in a index folder buffer."
7233 (save-excursion 7243 (save-excursion
7234 (mh-index-previous-folder) 7244 (mh-index-previous-folder)
7235 (if (not (re-search-forward "^\\(+.*\\)$" nil t)) 7245 (re-search-forward "^\\(+.*\\)$" nil t)
7236 (message "Problem getting folder from index.") 7246 (message (match-string 1))))
7237 (message (match-string 1)))))
7238 7247
7239 (defun org-mhe-get-message-folder () 7248 (defun org-mhe-get-message-folder ()
7240 "Return the name of the current message folder. Be careful if you 7249 "Return the name of the current message folder. Be careful if you
7241 use sequences." 7250 use sequences."
7242 (save-excursion 7251 (save-excursion
7276 7285
7277 (defun org-follow-mhe-link (folder article) 7286 (defun org-follow-mhe-link (folder article)
7278 "Follow an MHE link to FOLDER and ARTICLE." 7287 "Follow an MHE link to FOLDER and ARTICLE."
7279 (setq article (org-add-angle-brackets article)) 7288 (setq article (org-add-angle-brackets article))
7280 (require 'mh-e) 7289 (require 'mh-e)
7290 (require 'mh-search)
7281 (mh-find-path) 7291 (mh-find-path)
7282 (let* ((show-buf (concat "show-" folder))) 7292 (mh-search-choose)
7283 (mh-visit-folder folder) 7293 (if (equal mh-searcher 'pick)
7284 (get-buffer-create show-buf) 7294 (progn
7285 (mh-show-msg 7295 (mh-search folder (list "--message-id" article))
7286 (string-to-number 7296 (when (and org-mhe-search-all-folders
7287 (car (split-string 7297 (not (org-mhe-get-message-real-folder)))
7288 (with-temp-buffer 7298 (kill-this-buffer)
7289 (call-process 7299 (mh-search "+" (list "--message-id" article))))
7290 (expand-file-name "pick" mh-progs) 7300 (mh-search "+" article))
7291 nil t nil 7301 (if (org-mhe-get-message-real-folder)
7292 folder 7302 (mh-show-msg 1)
7293 "--message-id" 7303 (kill-this-buffer)
7294 article) 7304 (error "Message not found")))
7295 (buffer-string))
7296 "\n"))))
7297 (pop-to-buffer show-buf)))
7298 7305
7299 (defun org-open-file (path &optional in-emacs line search) 7306 (defun org-open-file (path &optional in-emacs line search)
7300 "Open the file at PATH. 7307 "Open the file at PATH.
7301 First, this expands any special file name abbreviations. Then the 7308 First, this expands any special file name abbreviations. Then the
7302 configuration variable `org-file-apps' is checked if it contains an 7309 configuration variable `org-file-apps' is checked if it contains an
7307 search for. If LINE or SEARCH is given, the file will always be 7314 search for. If LINE or SEARCH is given, the file will always be
7308 opened in Emacs. 7315 opened in Emacs.
7309 If the file does not exist, an error is thrown." 7316 If the file does not exist, an error is thrown."
7310 (setq in-emacs (or in-emacs line search)) 7317 (setq in-emacs (or in-emacs line search))
7311 (let* ((file (if (equal path "") 7318 (let* ((file (if (equal path "")
7312 (buffer-file-name) 7319 buffer-file-name
7313 (convert-standard-filename (org-expand-file-name path)))) 7320 (convert-standard-filename (org-expand-file-name path))))
7314 (dirp (file-directory-p file)) 7321 (dirp (file-directory-p file))
7315 (dfile (downcase file)) 7322 (dfile (downcase file))
7316 (old-buffer (current-buffer)) 7323 (old-buffer (current-buffer))
7317 (old-pos (point)) 7324 (old-pos (point))
7343 (setq cmd (format cmd (concat "\"" file "\""))) 7350 (setq cmd (format cmd (concat "\"" file "\"")))
7344 (save-window-excursion 7351 (save-window-excursion
7345 (shell-command (concat cmd " &")))) 7352 (shell-command (concat cmd " &"))))
7346 ((or (stringp cmd) 7353 ((or (stringp cmd)
7347 (eq cmd 'emacs)) 7354 (eq cmd 'emacs))
7348 (unless (equal (file-truename file) (file-truename (buffer-file-name))) 7355 (unless (equal (file-truename file) (file-truename buffer-file-name))
7349 (funcall (cdr (assq 'file org-link-frame-setup)) file)) 7356 (funcall (cdr (assq 'file org-link-frame-setup)) file))
7350 (if line (goto-line line) 7357 (if line (goto-line line)
7351 (if search (org-link-search search)))) 7358 (if search (org-link-search search))))
7352 ((consp cmd) 7359 ((consp cmd)
7353 (eval cmd)) 7360 (eval cmd))
7410 (and (eq major-mode 'vm-presentation-mode) (vm-summarize)) 7417 (and (eq major-mode 'vm-presentation-mode) (vm-summarize))
7411 (vm-follow-summary-cursor) 7418 (vm-follow-summary-cursor)
7412 (save-excursion 7419 (save-excursion
7413 (vm-select-folder-buffer) 7420 (vm-select-folder-buffer)
7414 (let* ((message (car vm-message-pointer)) 7421 (let* ((message (car vm-message-pointer))
7415 (folder (buffer-file-name)) 7422 (folder buffer-file-name)
7416 (subject (vm-su-subject message)) 7423 (subject (vm-su-subject message))
7417 (author (vm-su-full-name message)) 7424 (author (vm-su-full-name message))
7418 (message-id (vm-su-message-id message))) 7425 (message-id (vm-su-message-id message)))
7419 (setq message-id (org-remove-angle-brackets message-id)) 7426 (setq message-id (org-remove-angle-brackets message-id))
7420 (setq folder (abbreviate-file-name folder)) 7427 (setq folder (abbreviate-file-name folder))
7455 7462
7456 ((eq major-mode 'rmail-mode) 7463 ((eq major-mode 'rmail-mode)
7457 (save-excursion 7464 (save-excursion
7458 (save-restriction 7465 (save-restriction
7459 (rmail-narrow-to-non-pruned-header) 7466 (rmail-narrow-to-non-pruned-header)
7460 (let ((folder (buffer-file-name)) 7467 (let ((folder buffer-file-name)
7461 (message-id (mail-fetch-field "message-id")) 7468 (message-id (mail-fetch-field "message-id"))
7462 (author (mail-fetch-field "from")) 7469 (author (mail-fetch-field "from"))
7463 (subject (mail-fetch-field "subject"))) 7470 (subject (mail-fetch-field "subject")))
7464 (setq message-id (org-remove-angle-brackets message-id)) 7471 (setq message-id (org-remove-angle-brackets message-id))
7465 (setq cpltxt (concat author " on: " subject)) 7472 (setq cpltxt (concat author " on: " subject))
7510 link (org-make-link cpltxt))) 7517 link (org-make-link cpltxt)))
7511 7518
7512 ((eq major-mode 'org-mode) 7519 ((eq major-mode 'org-mode)
7513 ;; Just link to current headline 7520 ;; Just link to current headline
7514 (setq cpltxt (concat "file:" 7521 (setq cpltxt (concat "file:"
7515 (abbreviate-file-name (buffer-file-name)))) 7522 (abbreviate-file-name buffer-file-name)))
7516 ;; Add a context search string 7523 ;; Add a context search string
7517 (when (org-xor org-context-in-file-links arg) 7524 (when (org-xor org-context-in-file-links arg)
7518 ;; Check if we are on a target 7525 ;; Check if we are on a target
7519 (if (save-excursion 7526 (if (save-excursion
7520 (skip-chars-forward "^>\n\r") 7527 (skip-chars-forward "^>\n\r")
7535 (org-make-org-heading-search-string txt)))))) 7542 (org-make-org-heading-search-string txt))))))
7536 (if (string-match "::\\'" cpltxt) 7543 (if (string-match "::\\'" cpltxt)
7537 (setq cpltxt (substring cpltxt 0 -2))) 7544 (setq cpltxt (substring cpltxt 0 -2)))
7538 (setq link (org-make-link cpltxt))) 7545 (setq link (org-make-link cpltxt)))
7539 7546
7540 ((buffer-file-name) 7547 (buffer-file-name
7541 ;; Just link to this file here. 7548 ;; Just link to this file here.
7542 (setq cpltxt (concat "file:" 7549 (setq cpltxt (concat "file:"
7543 (abbreviate-file-name (buffer-file-name)))) 7550 (abbreviate-file-name buffer-file-name)))
7544 ;; Add a context string 7551 ;; Add a context string
7545 (when (org-xor org-context-in-file-links arg) 7552 (when (org-xor org-context-in-file-links arg)
7546 (setq txt (if (org-region-active-p) 7553 (setq txt (if (org-region-active-p)
7547 (buffer-substring (region-beginning) (region-end)) 7554 (buffer-substring (region-beginning) (region-end))
7548 (buffer-substring (point-at-bol) (point-at-eol)))) 7555 (buffer-substring (point-at-bol) (point-at-eol))))
7704 (when (string-match "<\\<file:\\(.+?\\)::\\([^>]+\\)>" link) 7711 (when (string-match "<\\<file:\\(.+?\\)::\\([^>]+\\)>" link)
7705 (let* ((path (match-string 1 link)) 7712 (let* ((path (match-string 1 link))
7706 (case-fold-search nil) 7713 (case-fold-search nil)
7707 (search (match-string 2 link))) 7714 (search (match-string 2 link)))
7708 (when (save-match-data 7715 (when (save-match-data
7709 (equal (file-truename (buffer-file-name)) 7716 (equal (file-truename buffer-file-name)
7710 (file-truename path))) 7717 (file-truename path)))
7711 ;; We are linking to this same file 7718 ;; We are linking to this same file
7712 (if (and org-file-link-context-use-camel-case 7719 (if (and org-file-link-context-use-camel-case
7713 (save-match-data 7720 (save-match-data
7714 (string-match (concat "^" org-camel-regexp "$") search))) 7721 (string-match (concat "^" org-camel-regexp "$") search)))
7833 (if (not (bolp)) (newline)) 7840 (if (not (bolp)) (newline))
7834 (org-paste-subtree (or current-prefix-arg 2) txt))) 7841 (org-paste-subtree (or current-prefix-arg 2) txt)))
7835 ((and (org-on-heading-p nil) (not current-prefix-arg)) 7842 ((and (org-on-heading-p nil) (not current-prefix-arg))
7836 ;; Put it below this entry, at the beg/end of the subtree 7843 ;; Put it below this entry, at the beg/end of the subtree
7837 (org-back-to-heading) 7844 (org-back-to-heading)
7838 (setq level (outline-level)) 7845 (setq level (funcall outline-level))
7839 (if reversed 7846 (if reversed
7840 (outline-end-of-heading) 7847 (outline-end-of-heading)
7841 (outline-end-of-subtree)) 7848 (outline-end-of-subtree))
7842 (if (not (bolp)) (newline)) 7849 (if (not (bolp)) (newline))
7843 (beginning-of-line 1) 7850 (beginning-of-line 1)
7866 ((not (listp org-reverse-note-order)) nil) 7873 ((not (listp org-reverse-note-order)) nil)
7867 (t (catch 'exit 7874 (t (catch 'exit
7868 (let ((all org-reverse-note-order) 7875 (let ((all org-reverse-note-order)
7869 entry) 7876 entry)
7870 (while (setq entry (pop all)) 7877 (while (setq entry (pop all))
7871 (if (string-match (car entry) (buffer-file-name)) 7878 (if (string-match (car entry) buffer-file-name)
7872 (throw 'exit (cdr entry)))) 7879 (throw 'exit (cdr entry))))
7873 nil))))) 7880 nil)))))
7874 7881
7875 ;;; Tables 7882 ;;; Tables
7876 7883
10508 10515
10509 (defun org-cleaned-string-for-export (string) 10516 (defun org-cleaned-string-for-export (string)
10510 "Cleanup a buffer substring so that links can be created safely." 10517 "Cleanup a buffer substring so that links can be created safely."
10511 (interactive) 10518 (interactive)
10512 (let* ((cb (current-buffer)) 10519 (let* ((cb (current-buffer))
10513 (re-radio (concat "\\([^<]\\)\\(" org-target-link-regexp "\\)")) 10520 (re-radio (and org-target-link-regexp
10521 (concat "\\([^<]\\)\\(" org-target-link-regexp "\\)")))
10514 rtn) 10522 rtn)
10515 (save-excursion 10523 (save-excursion
10516 (set-buffer (get-buffer-create " org-mode-tmp")) 10524 (set-buffer (get-buffer-create " org-mode-tmp"))
10517 (erase-buffer) 10525 (erase-buffer)
10518 (insert string) 10526 (insert string)
10522 (goto-char (point-min)) 10530 (goto-char (point-min))
10523 (while (re-search-forward "^#.*?\\(<<<?[^>\r\n]+>>>?\\).*" nil t) 10531 (while (re-search-forward "^#.*?\\(<<<?[^>\r\n]+>>>?\\).*" nil t)
10524 (replace-match "\\1(INVISIBLE)")) 10532 (replace-match "\\1(INVISIBLE)"))
10525 ;; Find matches for radio targets and turn them into links 10533 ;; Find matches for radio targets and turn them into links
10526 (goto-char (point-min)) 10534 (goto-char (point-min))
10527 (while (re-search-forward re-radio nil t) 10535 (when re-radio
10528 (replace-match "\\1[[\\2]]")) 10536 (while (re-search-forward re-radio nil t)
10537 (replace-match "\\1[[\\2]]")))
10529 ;; Find all links that contain a newline and put them into a single line 10538 ;; Find all links that contain a newline and put them into a single line
10530 (goto-char (point-min)) 10539 (goto-char (point-min))
10531 (while (re-search-forward "\\(\\[\\[[^]]*?\\)[ \t]*\n[ \t]*\\([^]]*\\]\\]\\)" nil t) 10540 (while (re-search-forward "\\(\\[\\[[^]]*?\\)[ \t]*\n[ \t]*\\([^]]*\\]\\]\\)" nil t)
10532 (replace-match "\\1 \\2") 10541 (replace-match "\\1 \\2")
10533 (goto-char (match-beginning 0))) 10542 (goto-char (match-beginning 0)))
10588 "[\r\n]")))) 10597 "[\r\n]"))))
10589 (org-startup-with-deadline-check nil) 10598 (org-startup-with-deadline-check nil)
10590 (level 0) line txt 10599 (level 0) line txt
10591 (umax nil) 10600 (umax nil)
10592 (case-fold-search nil) 10601 (case-fold-search nil)
10593 (filename (concat (file-name-sans-extension (buffer-file-name)) 10602 (filename (concat (file-name-sans-extension buffer-file-name)
10594 ".txt")) 10603 ".txt"))
10595 (buffer (find-file-noselect filename)) 10604 (buffer (find-file-noselect filename))
10596 (levels-open (make-vector org-level-max nil)) 10605 (levels-open (make-vector org-level-max nil))
10597 (date (format-time-string "%Y/%m/%d" (current-time))) 10606 (date (format-time-string "%Y/%m/%d" (current-time)))
10598 (time (format-time-string "%X" (current-time))) 10607 (time (format-time-string "%X" (current-time)))
10746 (defun org-export-copy-visible () 10755 (defun org-export-copy-visible ()
10747 "Copy the visible part of the buffer to another buffer, for printing. 10756 "Copy the visible part of the buffer to another buffer, for printing.
10748 Also removes the first line of the buffer if it specifies a mode, 10757 Also removes the first line of the buffer if it specifies a mode,
10749 and all options lines." 10758 and all options lines."
10750 (interactive) 10759 (interactive)
10751 (let* ((filename (concat (file-name-sans-extension (buffer-file-name)) 10760 (let* ((filename (concat (file-name-sans-extension buffer-file-name)
10752 ".txt")) 10761 ".txt"))
10753 (buffer (find-file-noselect filename)) 10762 (buffer (find-file-noselect filename))
10754 (ore (concat 10763 (ore (concat
10755 (org-make-options-regexp 10764 (org-make-options-regexp
10756 '("CATEGORY" "SEQ_TODO" "PRI_TODO" "TYP_TODO" 10765 '("CATEGORY" "SEQ_TODO" "PRI_TODO" "TYP_TODO"
10820 org-export-with-fixed-width 10829 org-export-with-fixed-width
10821 org-export-with-tables 10830 org-export-with-tables
10822 org-export-with-sub-superscripts 10831 org-export-with-sub-superscripts
10823 org-export-with-emphasize 10832 org-export-with-emphasize
10824 org-export-with-TeX-macros 10833 org-export-with-TeX-macros
10825 (file-name-nondirectory (buffer-file-name)) 10834 (file-name-nondirectory buffer-file-name)
10826 (if (equal org-todo-interpretation 'sequence) 10835 (if (equal org-todo-interpretation 'sequence)
10827 (mapconcat 'identity org-todo-keywords " ") 10836 (mapconcat 'identity org-todo-keywords " ")
10828 "TODO FEEDBACK VERIFY DONE") 10837 "TODO FEEDBACK VERIFY DONE")
10829 (if (equal org-todo-interpretation 'type) 10838 (if (equal org-todo-interpretation 'type)
10830 (mapconcat 'identity org-todo-keywords " ") 10839 (mapconcat 'identity org-todo-keywords " ")
10893 If there is an active region, export only the region. 10902 If there is an active region, export only the region.
10894 The prefix ARG specifies how many levels of the outline should become 10903 The prefix ARG specifies how many levels of the outline should become
10895 headlines. The default is 3. Lower levels will become bulleted lists." 10904 headlines. The default is 3. Lower levels will become bulleted lists."
10896 (interactive "P") 10905 (interactive "P")
10897 (org-export-as-html arg 'hidden) 10906 (org-export-as-html arg 'hidden)
10898 (org-open-file (buffer-file-name))) 10907 (org-open-file buffer-file-name))
10899 10908
10900 (defun org-export-as-html-batch () 10909 (defun org-export-as-html-batch ()
10901 "Call `org-export-as-html', may be used in batch processing as 10910 "Call `org-export-as-html', may be used in batch processing as
10902 emacs --batch 10911 emacs --batch
10903 --load=$HOME/lib/emacs/org.el 10912 --load=$HOME/lib/emacs/org.el
10925 (org-cleaned-string-for-export region) 10934 (org-cleaned-string-for-export region)
10926 "[\r\n]"))) 10935 "[\r\n]")))
10927 (lines (org-export-find-first-heading-line all_lines)) 10936 (lines (org-export-find-first-heading-line all_lines))
10928 (level 0) (line "") (origline "") txt todo 10937 (level 0) (line "") (origline "") txt todo
10929 (umax nil) 10938 (umax nil)
10930 (filename (concat (file-name-sans-extension (buffer-file-name)) 10939 (filename (concat (file-name-sans-extension buffer-file-name)
10931 ".html")) 10940 ".html"))
10932 (buffer (find-file-noselect filename)) 10941 (buffer (find-file-noselect filename))
10933 (levels-open (make-vector org-level-max nil)) 10942 (levels-open (make-vector org-level-max nil))
10934 (date (format-time-string "%Y/%m/%d" (current-time))) 10943 (date (format-time-string "%Y/%m/%d" (current-time)))
10935 (time (format-time-string "%X" (current-time))) 10944 (time (format-time-string "%X" (current-time)))
11659 (defun org-export-icalendar-this-file () 11668 (defun org-export-icalendar-this-file ()
11660 "Export current file as an iCalendar file. 11669 "Export current file as an iCalendar file.
11661 The iCalendar file will be located in the same directory as the Org-mode 11670 The iCalendar file will be located in the same directory as the Org-mode
11662 file, but with extension `.ics'." 11671 file, but with extension `.ics'."
11663 (interactive) 11672 (interactive)
11664 (org-export-icalendar nil (buffer-file-name))) 11673 (org-export-icalendar nil buffer-file-name))
11665 11674
11666 ;;;###autoload 11675 ;;;###autoload
11667 (defun org-export-icalendar-all-agenda-files () 11676 (defun org-export-icalendar-all-agenda-files ()
11668 "Export all files in `org-agenda-files' to iCalendar .ics files. 11677 "Export all files in `org-agenda-files' to iCalendar .ics files.
11669 Each iCalendar file will be located in the same directory as the Org-mode 11678 Each iCalendar file will be located in the same directory as the Org-mode
11696 (setq ical-buffer (org-get-agenda-file-buffer ical-file)) 11705 (setq ical-buffer (org-get-agenda-file-buffer ical-file))
11697 (set-buffer ical-buffer) (erase-buffer)) 11706 (set-buffer ical-buffer) (erase-buffer))
11698 (set-buffer (org-get-agenda-file-buffer file)) 11707 (set-buffer (org-get-agenda-file-buffer file))
11699 (setq category (or org-category 11708 (setq category (or org-category
11700 (file-name-sans-extension 11709 (file-name-sans-extension
11701 (file-name-nondirectory (buffer-file-name))))) 11710 (file-name-nondirectory buffer-file-name))))
11702 (if (symbolp category) (setq category (symbol-name category))) 11711 (if (symbolp category) (setq category (symbol-name category)))
11703 (let ((standard-output ical-buffer)) 11712 (let ((standard-output ical-buffer))
11704 (if combine 11713 (if combine
11705 (and (not started) (setq started t) 11714 (and (not started) (setq started t)
11706 (org-start-icalendar-file org-icalendar-combined-name)) 11715 (org-start-icalendar-file org-icalendar-combined-name))
12840 12849
12841 (run-hooks 'org-load-hook) 12850 (run-hooks 'org-load-hook)
12842 12851
12843 ;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd 12852 ;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd
12844 ;;; org.el ends here 12853 ;;; org.el ends here
12845