comparison lisp/textmodes/org.el @ 71096:d26859871d39

(org-agenda-highlight-todo): Make sure regexp does only match in the right place. (org-upcoming-deadline): New face. (org-agenda-get-deadlines): Use new face `org-upcoming-deadline'. (org-export-ascii-underline): Renamed and made an option (was constant `org-ascii-underline'). (org-export-ascii-bullets): New option. (org-export-as-html): Many changes to emit valid XHTML. (org-par-open): New variable. (org-open-par, org-close-par-maybe, org-close-li-maybe): New functions. (org-html-do-expand, org-section-number): Fixedcase in `replace-match'. (org-timeline): Pass `org-timeline-show-empty-dates' to `org-get-all-dates'. Interpret empty dates returned by `org-get-all-dates'. (org-get-all-dates): New argument EMPTY. Add dates without entries to the list, mark large ranges of empty dates. (org-point-in-group, org-context): New functions.
author Carsten Dominik <dominik@science.uva.nl>
date Tue, 30 May 2006 16:29:02 +0000
parents 971aad463b69
children 11ad1dbc7d45
comparison
equal deleted inserted replaced
71095:92e88635d2f4 71096:d26859871d39
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.34 8 ;; Version: 4.35
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.35
94 ;; - HTML export is now valid XHTML.
95 ;; - Timeline can also show dates without entries. See new option
96 ;; `org-timeline-show-empty-dates'.
97 ;; - The bullets created by the ASCII exporter can now be configured.
98 ;; See the new option `org-export-ascii-bullets'.
99 ;; - New face `org-upcoming-deadline' (was `org-scheduled-previously').
100 ;; - New function `org-context' to allow testing for local context.
101 ;;
93 ;; Version 4.34 102 ;; Version 4.34
94 ;; - Bug fixes. 103 ;; - Bug fixes.
95 ;; 104 ;;
96 ;; Version 4.33 105 ;; Version 4.33
97 ;; - New commands to move through plain lists: S-up and S-down. 106 ;; - New commands to move through plain lists: S-up and S-down.
154 (require 'time-date) 163 (require 'time-date)
155 (require 'easymenu) 164 (require 'easymenu)
156 165
157 ;;; Customization variables 166 ;;; Customization variables
158 167
159 (defvar org-version "4.34" 168 (defvar org-version "4.35"
160 "The version number of the file org.el.") 169 "The version number of the file org.el.")
161 (defun org-version () 170 (defun org-version ()
162 (interactive) 171 (interactive)
163 (message "Org-mode version %s" org-version)) 172 (message "Org-mode version %s" org-version))
164 173
1428 (defcustom org-agenda-start-with-follow-mode nil 1437 (defcustom org-agenda-start-with-follow-mode nil
1429 "The initial value of follwo-mode in a newly created agenda window." 1438 "The initial value of follwo-mode in a newly created agenda window."
1430 :group 'org-agenda-setup 1439 :group 'org-agenda-setup
1431 :type 'boolean) 1440 :type 'boolean)
1432 1441
1433 (defcustom org-select-timeline-window t
1434 "Non-nil means, after creating a timeline, move cursor into Timeline window.
1435 When nil, cursor will remain in the current window."
1436 :group 'org-agenda-setup
1437 :type 'boolean)
1438
1439 (defcustom org-select-agenda-window t 1442 (defcustom org-select-agenda-window t
1440 "Non-nil means, after creating an agenda, move cursor into Agenda window. 1443 "Non-nil means, after creating an agenda, move cursor into Agenda window.
1441 When nil, cursor will remain in the current window." 1444 When nil, cursor will remain in the current window."
1442 :group 'org-agenda-setup 1445 :group 'org-agenda-setup
1443 :type 'boolean) 1446 :type 'boolean)
1611 1614
1612 (setq org-agenda-prefix-format \" %-11:c% s\") 1615 (setq org-agenda-prefix-format \" %-11:c% s\")
1613 1616
1614 See also the variables `org-agenda-remove-times-when-in-prefix' and 1617 See also the variables `org-agenda-remove-times-when-in-prefix' and
1615 `org-agenda-remove-tags-when-in-prefix'." 1618 `org-agenda-remove-tags-when-in-prefix'."
1616 :type 'string
1617 :group 'org-agenda-prefix)
1618
1619 (defcustom org-timeline-prefix-format " % s"
1620 "Like `org-agenda-prefix-format', but for the timeline of a single file."
1621 :type 'string 1619 :type 'string
1622 :group 'org-agenda-prefix) 1620 :group 'org-agenda-prefix)
1623 1621
1624 (defvar org-prefix-format-compiled nil 1622 (defvar org-prefix-format-compiled nil
1625 "The compiled version of the most recently used prefix format. 1623 "The compiled version of the most recently used prefix format.
1651 :group 'org-agenda-prefix 1649 :group 'org-agenda-prefix
1652 :type '(choice 1650 :type '(choice
1653 (const :tag "Always" t) 1651 (const :tag "Always" t)
1654 (const :tag "Never" nil) 1652 (const :tag "Never" nil)
1655 (const :tag "When prefix format contains %T" prefix))) 1653 (const :tag "When prefix format contains %T" prefix)))
1654
1655 (defgroup org-agenda-timeline nil
1656 "Options concerning the timeline buffer in Org Mode."
1657 :tag "Org Agenda Timeline"
1658 :group 'org-agenda)
1659
1660 (defcustom org-timeline-prefix-format " % s"
1661 "Like `org-agenda-prefix-format', but for the timeline of a single file."
1662 :type 'string
1663 :group 'org-agenda-timeline)
1664
1665 (defcustom org-select-timeline-window t
1666 "Non-nil means, after creating a timeline, move cursor into Timeline window.
1667 When nil, cursor will remain in the current window."
1668 :group 'org-agenda-timeline
1669 :type 'boolean)
1670
1671 (defcustom org-timeline-show-empty-dates 3
1672 "Non-nil means, `org-timeline' also shows dates without an entry.
1673 When nil, only the days which actually have entries are shown.
1674 When t, all days between the first and the last date are shown.
1675 When an integer, show also empty dates, but if there is a gap of more than
1676 N days, just insert a special line indicating the size of the gap."
1677 :group 'org-agenda-timeline
1678 :type '(choice
1679 (const :tag "None" nil)
1680 (const :tag "All" t)
1681 (number :tag "at most")))
1656 1682
1657 (defgroup org-export nil 1683 (defgroup org-export nil
1658 "Options for exporting org-listings." 1684 "Options for exporting org-listings."
1659 :tag "Org Export" 1685 :tag "Org Export"
1660 :group 'org) 1686 :group 'org)
1887 1913
1888 (defgroup org-export-ascii nil 1914 (defgroup org-export-ascii nil
1889 "Options specific for ASCII export of Org-mode files." 1915 "Options specific for ASCII export of Org-mode files."
1890 :tag "Org Export ASCII" 1916 :tag "Org Export ASCII"
1891 :group 'org-export) 1917 :group 'org-export)
1918
1919 (defcustom org-export-ascii-underline '(?\$ ?\# ?^ ?\~ ?\= ?\-)
1920 "Characters for underlining headings in ASCII export.
1921 In the given sequence, these characters will be used for level 1, 2, ..."
1922 :group 'org-export-ascii
1923 :type '(repeat character))
1924
1925 (defcustom org-export-ascii-bullets '(?* ?o ?-)
1926 "Bullet characters for headlines converted to lists in ASCII export.
1927 The first character is is used for the first lest level generated in this
1928 way, and so on. If there are more levels than characters given here,
1929 the list will be repeated.
1930 Note that plain lists will keep the same bullets as the have in the
1931 Org-mode file."
1932 :group 'org-export-ascii
1933 :type '(repeat character))
1892 1934
1893 (defcustom org-export-ascii-show-new-buffer t 1935 (defcustom org-export-ascii-show-new-buffer t
1894 "Non-nil means, popup buffer containing the exported ASCII text. 1936 "Non-nil means, popup buffer containing the exported ASCII text.
1895 Otherwise the buffer will just be saved to a file and stay hidden." 1937 Otherwise the buffer will just be saved to a file and stay hidden."
1896 :group 'org-export-ascii 1938 :group 'org-export-ascii
1995 This option can also be set with the +OPTIONS line, e.g. \"@:nil\"." 2037 This option can also be set with the +OPTIONS line, e.g. \"@:nil\"."
1996 :group 'org-export-html 2038 :group 'org-export-html
1997 :type 'boolean) 2039 :type 'boolean)
1998 2040
1999 (defcustom org-export-html-table-tag 2041 (defcustom org-export-html-table-tag
2000 "<table border=1 cellspacing=0 cellpadding=6>" 2042 "<table border=\"1\" cellspacing=\"0\" cellpadding=\"6\">"
2001 "The HTML tag used to start a table. 2043 "The HTML tag used to start a table.
2002 This must be a <table> tag, but you may change the options like 2044 This must be a <table> tag, but you may change the options like
2003 borders and spacing." 2045 borders and spacing."
2004 :group 'org-export-html 2046 :group 'org-export-html
2005 :type 'string) 2047 :type 'string)
2009 into the exported HTML text. Otherwise, the buffer will just be saved 2051 into the exported HTML text. Otherwise, the buffer will just be saved
2010 to a file." 2052 to a file."
2011 :group 'org-export-html 2053 :group 'org-export-html
2012 :type 'boolean) 2054 :type 'boolean)
2013 2055
2056 ;; FIXME: <br><br> is not pretty.
2014 (defcustom org-export-html-html-helper-timestamp 2057 (defcustom org-export-html-html-helper-timestamp
2015 "<br><br><hr><p><!-- hhmts start --> <!-- hhmts end -->\n" 2058 "<br/><br/><hr><p><!-- hhmts start --> <!-- hhmts end --></p>\n"
2016 "The HTML tag used as timestamp delimiter for HTML-helper-mode." 2059 "The HTML tag used as timestamp delimiter for HTML-helper-mode."
2017 :group 'org-export-html 2060 :group 'org-export-html
2018 :type 'string) 2061 :type 'string)
2019 2062
2020 (defcustom org-export-html-show-new-buffer nil 2063 (defcustom org-export-html-show-new-buffer nil
2302 (((class color) (min-colors 8) (background dark)) (:foreground "red" :bold t)) 2345 (((class color) (min-colors 8) (background dark)) (:foreground "red" :bold t))
2303 (t (:bold t)))) 2346 (t (:bold t))))
2304 "Face for items scheduled previously, and not yet done." 2347 "Face for items scheduled previously, and not yet done."
2305 :group 'org-faces) 2348 :group 'org-faces)
2306 2349
2350 (defface org-upcoming-deadline
2351 (org-compatible-face
2352 '((((class color) (min-colors 88) (background light)) (:foreground "Firebrick"))
2353 (((class color) (min-colors 88) (background dark)) (:foreground "chocolate1"))
2354 (((class color) (min-colors 8) (background light)) (:foreground "red"))
2355 (((class color) (min-colors 8) (background dark)) (:foreground "red" :bold t))
2356 (t (:bold t))))
2357 "Face for items scheduled previously, and not yet done."
2358 :group 'org-faces)
2359
2307 (defface org-time-grid ;; font-lock-variable-name-face 2360 (defface org-time-grid ;; font-lock-variable-name-face
2308 (org-compatible-face 2361 (org-compatible-face
2309 '((((class color) (min-colors 16) (background light)) (:foreground "DarkGoldenrod")) 2362 '((((class color) (min-colors 16) (background light)) (:foreground "DarkGoldenrod"))
2310 (((class color) (min-colors 16) (background dark)) (:foreground "LightGoldenrod")) 2363 (((class color) (min-colors 16) (background dark)) (:foreground "LightGoldenrod"))
2311 (((class color) (min-colors 8)) (:foreground "yellow" :weight light)))) 2364 (((class color) (min-colors 8)) (:foreground "yellow" :weight light))))
2345 "Matches any of the TODO state keywords except the last one.") 2398 "Matches any of the TODO state keywords except the last one.")
2346 (make-variable-buffer-local 'org-not-done-regexp) 2399 (make-variable-buffer-local 'org-not-done-regexp)
2347 (defvar org-todo-line-regexp nil 2400 (defvar org-todo-line-regexp nil
2348 "Matches a headline and puts TODO state into group 2 if present.") 2401 "Matches a headline and puts TODO state into group 2 if present.")
2349 (make-variable-buffer-local 'org-todo-line-regexp) 2402 (make-variable-buffer-local 'org-todo-line-regexp)
2403 (defvar org-todo-line-tags-regexp nil
2404 "Matches a headline and puts TODO state into group 2 if present.
2405 Also put tags into group 4 if tags are present.")
2406 (make-variable-buffer-local 'org-todo-line-tags-regexp)
2350 (defvar org-nl-done-regexp nil 2407 (defvar org-nl-done-regexp nil
2351 "Matches newline followed by a headline with the DONE keyword.") 2408 "Matches newline followed by a headline with the DONE keyword.")
2352 (make-variable-buffer-local 'org-nl-done-regexp) 2409 (make-variable-buffer-local 'org-nl-done-regexp)
2353 (defvar org-looking-at-done-regexp nil 2410 (defvar org-looking-at-done-regexp nil
2354 "Matches the DONE keyword a point.") 2411 "Matches the DONE keyword a point.")
2497 (concat "^\\(\\*+\\)[ \t]*\\(" 2554 (concat "^\\(\\*+\\)[ \t]*\\("
2498 (mapconcat 'regexp-quote org-todo-keywords "\\|") 2555 (mapconcat 'regexp-quote org-todo-keywords "\\|")
2499 "\\)? *\\(.*\\)") 2556 "\\)? *\\(.*\\)")
2500 org-nl-done-regexp 2557 org-nl-done-regexp
2501 (concat "[\r\n]\\*+[ \t]+" org-done-string "\\>") 2558 (concat "[\r\n]\\*+[ \t]+" org-done-string "\\>")
2559 org-todo-line-tags-regexp
2560 (concat "^\\(\\*+\\)[ \t]*\\("
2561 (mapconcat 'regexp-quote org-todo-keywords "\\|")
2562 "\\)? *\\(.*?\\([ \t]:[a-zA-Z0-9:_@]+:[ \t]*\\)?$\\)")
2502 org-looking-at-done-regexp (concat "^" org-done-string "\\>") 2563 org-looking-at-done-regexp (concat "^" org-done-string "\\>")
2503 org-deadline-regexp (concat "\\<" org-deadline-string) 2564 org-deadline-regexp (concat "\\<" org-deadline-string)
2504 org-deadline-time-regexp 2565 org-deadline-time-regexp
2505 (concat "\\<" org-deadline-string " *<\\([^>]+\\)>") 2566 (concat "\\<" org-deadline-string " *<\\([^>]+\\)>")
2506 org-deadline-line-regexp 2567 org-deadline-line-regexp
5563 (win (selected-window)) 5624 (win (selected-window))
5564 (pos1 (point)) 5625 (pos1 (point))
5565 (beg (if (org-region-active-p) (region-beginning) (point-min))) 5626 (beg (if (org-region-active-p) (region-beginning) (point-min)))
5566 (end (if (org-region-active-p) (region-end) (point-max))) 5627 (end (if (org-region-active-p) (region-end) (point-max)))
5567 (day-numbers (org-get-all-dates beg end 'no-ranges 5628 (day-numbers (org-get-all-dates beg end 'no-ranges
5568 t doclosed)) ; always include today 5629 t doclosed ; always include today
5630 org-timeline-show-empty-dates))
5569 (today (time-to-days (current-time))) 5631 (today (time-to-days (current-time)))
5570 (org-respect-restriction t) 5632 (org-respect-restriction t)
5571 (past t) 5633 (past t)
5572 args 5634 args
5573 s e rtn d) 5635 s e rtn d emptyp)
5574 (setq org-agenda-redo-command 5636 (setq org-agenda-redo-command
5575 (list 'progn 5637 (list 'progn
5576 (list 'switch-to-buffer-other-window (current-buffer)) 5638 (list 'switch-to-buffer-other-window (current-buffer))
5577 (list 'org-timeline (list 'quote include-all) t))) 5639 (list 'org-timeline (list 'quote include-all) t)))
5578 (if (not dopast) 5640 (if (not dopast)
5588 (set (make-local-variable 'org-agenda-type) 'timeline) 5650 (set (make-local-variable 'org-agenda-type) 'timeline)
5589 (if doclosed (push :closed args)) 5651 (if doclosed (push :closed args))
5590 (push :timestamp args) 5652 (push :timestamp args)
5591 (if dotodo (push :todo args)) 5653 (if dotodo (push :todo args))
5592 (while (setq d (pop day-numbers)) 5654 (while (setq d (pop day-numbers))
5593 (if (and (>= d today) 5655 (if (and (listp d) (eq (car d) :omitted))
5594 dopast
5595 past)
5596 (progn 5656 (progn
5597 (setq past nil) 5657 (setq s (point))
5598 (insert (make-string 79 ?-) "\n"))) 5658 (insert (format "\n[... %d empty days omitted]\n\n" (cdr d)))
5599 (setq date (calendar-gregorian-from-absolute d)) 5659 (put-text-property s (1- (point)) 'face 'org-level-3))
5600 (setq s (point)) 5660 (if (listp d) (setq d (car d) emptyp t) (setq emptyp nil))
5601 (setq rtn (apply 'org-agenda-get-day-entries 5661 (if (and (>= d today)
5602 entry date args)) 5662 dopast
5603 (if (or rtn (equal d today)) 5663 past)
5604 (progn 5664 (progn
5605 (insert (calendar-day-name date) " " 5665 (setq past nil)
5606 (number-to-string (extract-calendar-day date)) " " 5666 (insert (make-string 79 ?-) "\n")))
5607 (calendar-month-name (extract-calendar-month date)) " " 5667 (setq date (calendar-gregorian-from-absolute d))
5608 (number-to-string (extract-calendar-year date)) "\n") 5668 (setq s (point))
5609 (put-text-property s (1- (point)) 'face 5669 (setq rtn (and (not emptyp)
5610 'org-level-3) 5670 (apply 'org-agenda-get-day-entries
5611 (if (equal d today) 5671 entry date args)))
5612 (put-text-property s (1- (point)) 'org-today t)) 5672 (if (or rtn (equal d today) org-timeline-show-empty-dates)
5613 (insert (org-finalize-agenda-entries rtn) "\n") 5673 (progn
5614 (put-text-property s (1- (point)) 'day d)))) 5674 (insert (calendar-day-name date) " "
5675 (number-to-string (extract-calendar-day date)) " "
5676 (calendar-month-name (extract-calendar-month date)) " "
5677 (number-to-string (extract-calendar-year date)) "\n")
5678 (put-text-property s (1- (point)) 'face
5679 'org-level-3)
5680 (if (equal d today)
5681 (put-text-property s (1- (point)) 'org-today t))
5682 (and rtn (insert (org-finalize-agenda-entries rtn) "\n"))
5683 (put-text-property s (1- (point)) 'day d)))))
5615 (goto-char (point-min)) 5684 (goto-char (point-min))
5616 (setq buffer-read-only t) 5685 (setq buffer-read-only t)
5617 (goto-char (or (text-property-any (point-min) (point-max) 'org-today t) 5686 (goto-char (or (text-property-any (point-min) (point-max) 'org-today t)
5618 (point-min))) 5687 (point-min)))
5619 (when (not org-select-timeline-window) 5688 (when (not org-select-timeline-window)
6172 (message "File was not in list: %s" afile)))) 6241 (message "File was not in list: %s" afile))))
6173 6242
6174 (defun org-file-menu-entry (file) 6243 (defun org-file-menu-entry (file)
6175 (vector file (list 'find-file file) t)) 6244 (vector file (list 'find-file file) t))
6176 6245
6177 (defun org-get-all-dates (beg end &optional no-ranges force-today inactive) 6246 (defun org-get-all-dates (beg end &optional no-ranges force-today inactive empty)
6178 "Return a list of all relevant day numbers from BEG to END buffer positions. 6247 "Return a list of all relevant day numbers from BEG to END buffer positions.
6179 If NO-RANGES is non-nil, include only the start and end dates of a range, 6248 If NO-RANGES is non-nil, include only the start and end dates of a range,
6180 not every single day in the range. If FORCE-TODAY is non-nil, make 6249 not every single day in the range. If FORCE-TODAY is non-nil, make
6181 sure that TODAY is included in the list. If INACTIVE is non-nil, also 6250 sure that TODAY is included in the list. If INACTIVE is non-nil, also
6182 inactive time stamps (those in square brackets) are included." 6251 inactive time stamps (those in square brackets) are included.
6252 When EMPTY is non-nil, also include days without any entries."
6183 (let ((re (if inactive org-ts-regexp-both org-ts-regexp)) 6253 (let ((re (if inactive org-ts-regexp-both org-ts-regexp))
6184 dates date day day1 day2 ts1 ts2) 6254 dates dates1 date day day1 day2 ts1 ts2)
6185 (if force-today 6255 (if force-today
6186 (setq dates (list (time-to-days (current-time))))) 6256 (setq dates (list (time-to-days (current-time)))))
6187 (save-excursion 6257 (save-excursion
6188 (goto-char beg) 6258 (goto-char beg)
6189 (while (re-search-forward re end t) 6259 (while (re-search-forward re end t)
6197 ts2 (substring (match-string 2) 0 10) 6267 ts2 (substring (match-string 2) 0 10)
6198 day1 (time-to-days (org-time-string-to-time ts1)) 6268 day1 (time-to-days (org-time-string-to-time ts1))
6199 day2 (time-to-days (org-time-string-to-time ts2))) 6269 day2 (time-to-days (org-time-string-to-time ts2)))
6200 (while (< (setq day1 (1+ day1)) day2) 6270 (while (< (setq day1 (1+ day1)) day2)
6201 (or (memq day1 dates) (push day1 dates))))) 6271 (or (memq day1 dates) (push day1 dates)))))
6202 (sort dates '<)))) 6272 (setq dates (sort dates '<))
6273 (when empty
6274 (while (setq day (pop dates))
6275 (setq day2 (car dates))
6276 (push day dates1)
6277 (when (and day2 empty)
6278 (if (or (eq empty t)
6279 (and (numberp empty) (<= (- day2 day) empty)))
6280 (while (< (setq day (1+ day)) day2)
6281 (push (list day) dates1))
6282 (push (cons :omitted (- day2 day)) dates1))))
6283 (setq dates (nreverse dates1)))
6284 dates)))
6203 6285
6204 ;;;###autoload 6286 ;;;###autoload
6205 (defun org-diary (&rest args) 6287 (defun org-diary (&rest args)
6206 "Return diary information from org-files. 6288 "Return diary information from org-files.
6207 This function can be used in a \"sexp\" diary entry in the Emacs calendar. 6289 This function can be used in a \"sexp\" diary entry in the Emacs calendar.
6542 (abbreviate-file-name buffer-file-name)))) 6624 (abbreviate-file-name buffer-file-name))))
6543 (regexp org-deadline-time-regexp) 6625 (regexp org-deadline-time-regexp)
6544 (todayp (equal date (calendar-current-date))) ; DATE bound by calendar 6626 (todayp (equal date (calendar-current-date))) ; DATE bound by calendar
6545 (d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar 6627 (d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar
6546 d2 diff pos pos1 category tags 6628 d2 diff pos pos1 category tags
6547 ee txt head) 6629 ee txt head face)
6548 (goto-char (point-min)) 6630 (goto-char (point-min))
6549 (while (re-search-forward regexp nil t) 6631 (while (re-search-forward regexp nil t)
6550 (setq pos (1- (match-beginning 1)) 6632 (setq pos (1- (match-beginning 1))
6551 d2 (time-to-days 6633 d2 (time-to-days
6552 (org-time-string-to-time (match-string 1))) 6634 (org-time-string-to-time (match-string 1)))
6569 (if (string-match org-looking-at-done-regexp head) 6651 (if (string-match org-looking-at-done-regexp head)
6570 (setq txt nil) 6652 (setq txt nil)
6571 (setq txt (org-format-agenda-item 6653 (setq txt (org-format-agenda-item
6572 (format "In %3d d.: " diff) head category tags)))) 6654 (format "In %3d d.: " diff) head category tags))))
6573 (setq txt org-agenda-no-heading-message)) 6655 (setq txt org-agenda-no-heading-message))
6574 (when txt 6656 (when txt
6657 (setq face (cond ((<= diff 0) 'org-warning)
6658 ((<= diff 5) 'org-upcoming-deadline)
6659 (t nil)))
6575 (org-add-props txt props 6660 (org-add-props txt props
6576 'org-marker (org-agenda-new-marker pos) 6661 'org-marker (org-agenda-new-marker pos)
6577 'org-hd-marker (org-agenda-new-marker pos1) 6662 'org-hd-marker (org-agenda-new-marker pos1)
6578 'priority (+ (- 10 diff) (org-get-priority txt)) 6663 'priority (+ (- 10 diff) (org-get-priority txt))
6579 'category category 6664 'category category
6580 'face (cond ((<= diff 0) 'org-warning) 6665 'face face 'undone-face face 'done-face 'org-done)
6581 ((<= diff 5) 'org-scheduled-previously)
6582 (t nil))
6583 'undone-face (cond
6584 ((<= diff 0) 'org-warning)
6585 ((<= diff 5) 'org-scheduled-previously)
6586 (t nil))
6587 'done-face 'org-done)
6588 (push txt ee))))) 6666 (push txt ee)))))
6589 ee)) 6667 ee))
6590 6668
6591 (defun org-agenda-get-scheduled () 6669 (defun org-agenda-get-scheduled ()
6592 "Return the scheduled information for agenda display." 6670 "Return the scheduled information for agenda display."
6884 "Sort and concatenate the agenda items." 6962 "Sort and concatenate the agenda items."
6885 (setq list (mapcar 'org-agenda-highlight-todo list)) 6963 (setq list (mapcar 'org-agenda-highlight-todo list))
6886 (mapconcat 'identity (sort list 'org-entries-lessp) "\n")) 6964 (mapconcat 'identity (sort list 'org-entries-lessp) "\n"))
6887 6965
6888 (defun org-agenda-highlight-todo (x) 6966 (defun org-agenda-highlight-todo (x)
6889 (let (re) 6967 (let (re pl)
6890 (if (eq x 'line) 6968 (if (eq x 'line)
6891 (save-excursion 6969 (save-excursion
6892 (beginning-of-line 1) 6970 (beginning-of-line 1)
6893 (setq re (get-text-property (point) 'org-not-done-regexp)) 6971 (setq re (get-text-property (point) 'org-not-done-regexp))
6894 (goto-char (+ (point) (get-text-property (point) 'prefix-length))) 6972 (goto-char (+ (point) (get-text-property (point) 'prefix-length)))
6895 (and (looking-at (concat "[ \t]*" re)) 6973 (and (looking-at (concat "[ \t]*" re))
6896 (add-text-properties (match-beginning 0) (match-end 0) 6974 (add-text-properties (match-beginning 0) (match-end 0)
6897 '(face org-todo)))) 6975 '(face org-todo))))
6898 (setq re (get-text-property 0 'org-not-done-regexp x)) 6976 (setq re (get-text-property 0 'org-not-done-regexp x)
6899 (and re (string-match re x) 6977 pl (get-text-property 0 'prefix-length x))
6978 (and re (equal (string-match re x pl) pl)
6900 (add-text-properties (match-beginning 0) (match-end 0) 6979 (add-text-properties (match-beginning 0) (match-end 0)
6901 '(face org-todo) x)) 6980 '(face org-todo) x))
6902 x))) 6981 x)))
6903 6982
6904 (defsubst org-cmp-priority (a b) 6983 (defsubst org-cmp-priority (a b)
8718 (setq txt (cond 8797 (setq txt (cond
8719 ((org-on-heading-p) nil) 8798 ((org-on-heading-p) nil)
8720 ((org-region-active-p) 8799 ((org-region-active-p)
8721 (buffer-substring (region-beginning) (region-end))) 8800 (buffer-substring (region-beginning) (region-end)))
8722 (t (buffer-substring (point-at-bol) (point-at-eol))))) 8801 (t (buffer-substring (point-at-bol) (point-at-eol)))))
8723 (when (string-match "\\S-" txt) 8802 (when (or (null txt) (string-match "\\S-" txt))
8724 (setq cpltxt 8803 (setq cpltxt
8725 (concat cpltxt "::" 8804 (concat cpltxt "::"
8726 (if org-file-link-context-use-camel-case 8805 (if org-file-link-context-use-camel-case
8727 (org-make-org-heading-camel txt) 8806 (org-make-org-heading-camel txt)
8728 (org-make-org-heading-search-string txt))) 8807 (org-make-org-heading-search-string txt)))
11682 ) 11761 )
11683 (t (setq rtn (cons line rtn))))) 11762 (t (setq rtn (cons line rtn)))))
11684 (nreverse rtn))) 11763 (nreverse rtn)))
11685 11764
11686 ;; ASCII 11765 ;; ASCII
11687
11688 (defconst org-ascii-underline '(?\$ ?\# ?^ ?\~ ?\= ?\-)
11689 "Characters for underlining headings in ASCII export.")
11690 11766
11691 (defconst org-html-entities 11767 (defconst org-html-entities
11692 '(("nbsp") 11768 '(("nbsp")
11693 ("iexcl") 11769 ("iexcl")
11694 ("cent") 11770 ("cent")
12087 (defun org-tr-level (n) 12163 (defun org-tr-level (n)
12088 "Make N odd if required." 12164 "Make N odd if required."
12089 (if org-odd-levels-only (1+ (/ n 2)) n)) 12165 (if org-odd-levels-only (1+ (/ n 2)) n))
12090 12166
12091 (defvar org-last-level nil) ; dynamically scoped variable 12167 (defvar org-last-level nil) ; dynamically scoped variable
12168 (defvar org-ascii-current-indentation nil) ; For communication
12169 ;; FIXME: change indentation???/
12170
12092 12171
12093 (defun org-export-as-ascii (arg) 12172 (defun org-export-as-ascii (arg)
12094 "Export the outline as a pretty ASCII file. 12173 "Export the outline as a pretty ASCII file.
12095 If there is an active region, export only the region. 12174 If there is an active region, export only the region.
12096 The prefix ARG specifies how many levels of the outline should become 12175 The prefix ARG specifies how many levels of the outline should become
12106 (lines (org-export-find-first-heading-line 12185 (lines (org-export-find-first-heading-line
12107 (org-skip-comments 12186 (org-skip-comments
12108 (org-split-string 12187 (org-split-string
12109 (org-cleaned-string-for-export region) 12188 (org-cleaned-string-for-export region)
12110 "[\r\n]")))) 12189 "[\r\n]"))))
12190 (org-ascii-current-indentation "")
12111 (org-startup-with-deadline-check nil) 12191 (org-startup-with-deadline-check nil)
12112 (level 0) line txt 12192 (level 0) line txt
12113 (umax nil) 12193 (umax nil)
12114 (case-fold-search nil) 12194 (case-fold-search nil)
12115 (filename (concat (file-name-as-directory 12195 (filename (concat (file-name-as-directory
12219 (cond 12299 (cond
12220 ((string-match "^\\(\\*+\\)[ \t]*\\(.*\\)" line) 12300 ((string-match "^\\(\\*+\\)[ \t]*\\(.*\\)" line)
12221 ;; a Headline 12301 ;; a Headline
12222 (setq level (org-tr-level (- (match-end 1) (match-beginning 1))) 12302 (setq level (org-tr-level (- (match-end 1) (match-beginning 1)))
12223 txt (match-string 2 line)) 12303 txt (match-string 2 line))
12224 (org-ascii-level-start level txt umax)) 12304 (org-ascii-level-start level txt umax lines))
12225 (t (insert line "\n")))) 12305 (t
12306 ;; FIXME: do we need to do something about the indention when items are
12307 ;; converted to lists?
12308 (insert org-ascii-current-indentation line "\n"))))
12226 (normal-mode) 12309 (normal-mode)
12227 (save-buffer) 12310 (save-buffer)
12228 ;; remove display and invisible chars 12311 ;; remove display and invisible chars
12229 (let (beg end s) 12312 (let (beg end s)
12230 (goto-char (point-min)) 12313 (goto-char (point-min))
12274 (if underline 12357 (if underline
12275 (insert (make-string ind ?\ ) 12358 (insert (make-string ind ?\ )
12276 (make-string (string-width s) underline) 12359 (make-string (string-width s) underline)
12277 "\n")))) 12360 "\n"))))
12278 12361
12279 (defun org-ascii-level-start (level title umax) 12362 (defun org-ascii-level-start (level title umax &optional lines)
12280 "Insert a new level in ASCII export." 12363 "Insert a new level in ASCII export."
12281 (let (char) 12364 (let (char (n (- level umax 1)) (ind 0))
12282 (if (> level umax) 12365 (if (> level umax)
12283 (insert (make-string (* 2 (- level umax 1)) ?\ ) "* " title "\n") 12366 (progn
12367 (insert (make-string (* 2 n) ?\ )
12368 (char-to-string (nth (% n (length org-export-ascii-bullets))
12369 org-export-ascii-bullets))
12370 " " title "\n")
12371 ;; find the indentation of the next non-empty line
12372 (catch 'stop
12373 (while lines
12374 (if (string-match "^\\*" (car lines)) (throw 'stop nil))
12375 (if (string-match "^\\([ \t]*\\)\\S-" (car lines))
12376 (throw 'stop (setq ind (match-end 1))))
12377 (pop lines)))
12378 (setq org-ascii-current-indentation
12379 (make-string (max (- (* 2 (1+ n)) ind) 0) ?\ )))
12284 (if (or (not (equal (char-before) ?\n)) 12380 (if (or (not (equal (char-before) ?\n))
12285 (not (equal (char-before (1- (point))) ?\n))) 12381 (not (equal (char-before (1- (point))) ?\n)))
12286 (insert "\n")) 12382 (insert "\n"))
12287 (setq char (nth (- umax level) (reverse org-ascii-underline))) 12383 (setq char (nth (- umax level) (reverse org-export-ascii-underline)))
12288 (if org-export-with-section-numbers 12384 (if org-export-with-section-numbers
12289 (setq title (concat (org-section-number level) " " title))) 12385 (setq title (concat (org-section-number level) " " title)))
12290 (insert title "\n" (make-string (string-width title) char) "\n")))) 12386 (insert title "\n" (make-string (string-width title) char) "\n")
12387 (setq org-ascii-current-indentation ""))))
12291 12388
12292 (defun org-export-visible (type arg) 12389 (defun org-export-visible (type arg)
12293 "Create a copy of the visible part of the current buffer, and export it. 12390 "Create a copy of the visible part of the current buffer, and export it.
12294 The copy is created in a temporary buffer and removed after use. 12391 The copy is created in a temporary buffer and removed after use.
12295 TYPE is the final key (as a string) of the `C-c C-x' key sequence that will 12392 TYPE is the final key (as a string) of the `C-c C-x' key sequence that will
12570 (setq umax (if arg (prefix-numeric-value arg) 12667 (setq umax (if arg (prefix-numeric-value arg)
12571 org-export-headline-levels)) 12668 org-export-headline-levels))
12572 12669
12573 ;; File header 12670 ;; File header
12574 (insert (format 12671 (insert (format
12575 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" 12672 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
12576 \"http://www.w3.org/TR/REC-html40/loose.dtd\"> 12673 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
12577 <html lang=\"%s\"><head> 12674 <html xmlns=\"http://www.w3.org/1999/xhtml\"
12675 lang=\"%s\" xml:lang=\"%s\">
12676 <head>
12578 <title>%s</title> 12677 <title>%s</title>
12579 <meta http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"> 12678 <meta http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"/>
12580 <meta name=generator content=\"Org-mode\"> 12679 <meta name=\"generator\" content=\"Org-mode\"/>
12581 <meta name=generated content=\"%s %s\"> 12680 <meta name=\"generated\" content=\"%s %s\"/>
12582 <meta name=author content=\"%s\"> 12681 <meta name=\"author\" content=\"%s\"/>
12583 %s 12682 %s
12584 </head><body> 12683 </head><body>
12585 " 12684 "
12586 language (org-html-expand title) (or charset "iso-8859-1") 12685 language language (org-html-expand title) (or charset "iso-8859-1")
12587 date time author style)) 12686 date time author style))
12588 12687
12589 12688
12590 (insert (or (plist-get opt-plist :preamble) "")) 12689 (insert (or (plist-get opt-plist :preamble) ""))
12591 12690
12592 (when (plist-get opt-plist :auto-preamble) 12691 (when (plist-get opt-plist :auto-preamble)
12593 (if title (insert (concat "<H1 class=\"title\">" 12692 (if title (insert (concat "<h1 class=\"title\">"
12594 (org-html-expand title) "</H1>\n"))) 12693 (org-html-expand title) "</h1>\n")))
12595 ; (if author (insert (concat (nth 1 lang-words) ": " author "\n"))) 12694
12596 ; (if email (insert (concat "<a href=\"mailto:" email "\">&lt;" 12695 (if text (insert "<p>\n" (org-html-expand text) "</p>")))
12597 ; email "&gt;</a>\n")))
12598 ; (if (or author email) (insert "<br>\n"))
12599 ; (if (and date time) (insert (concat (nth 2 lang-words) ": "
12600 ; date " " time "<br>\n")))
12601 (if text (insert (concat "<p>\n" (org-html-expand text)))))
12602 12696
12603 (if org-export-with-toc 12697 (if org-export-with-toc
12604 (progn 12698 (progn
12605 (insert (format "<H2>%s</H2>\n" (nth 3 lang-words))) 12699 (insert (format "<h2>%s</h2>\n" (nth 3 lang-words)))
12606 (insert "<ul>\n") 12700 (insert "<ul>\n<li>")
12607 (setq lines 12701 (setq lines
12608 (mapcar '(lambda (line) 12702 (mapcar '(lambda (line)
12609 (if (string-match org-todo-line-regexp line) 12703 (if (string-match org-todo-line-regexp line)
12610 ;; This is a headline 12704 ;; This is a headline
12611 (progn 12705 (progn
12633 (setq head-count (+ head-count 1)) 12727 (setq head-count (+ head-count 1))
12634 (if (> level org-last-level) 12728 (if (> level org-last-level)
12635 (progn 12729 (progn
12636 (setq cnt (- level org-last-level)) 12730 (setq cnt (- level org-last-level))
12637 (while (>= (setq cnt (1- cnt)) 0) 12731 (while (>= (setq cnt (1- cnt)) 0)
12638 (insert "<ul>")) 12732 (insert "\n<ul>\n<li>"))
12639 (insert "\n"))) 12733 (insert "\n")))
12640 (if (< level org-last-level) 12734 (if (< level org-last-level)
12641 (progn 12735 (progn
12642 (setq cnt (- org-last-level level)) 12736 (setq cnt (- org-last-level level))
12643 (while (>= (setq cnt (1- cnt)) 0) 12737 (while (>= (setq cnt (1- cnt)) 0)
12644 (insert "</ul>")) 12738 (insert "</li>\n</ul>"))
12645 (insert "\n"))) 12739 (insert "\n")))
12646 ;; Check for targets 12740 ;; Check for targets
12647 (while (string-match org-target-regexp line) 12741 (while (string-match org-target-regexp line)
12648 (setq tg (match-string 1 line) 12742 (setq tg (match-string 1 line)
12649 line (replace-match 12743 line (replace-match
12655 (while (string-match "&lt;\\(&lt;\\)+\\|&gt;\\(&gt;\\)+" txt) 12749 (while (string-match "&lt;\\(&lt;\\)+\\|&gt;\\(&gt;\\)+" txt)
12656 (setq txt (replace-match "" t t txt))) 12750 (setq txt (replace-match "" t t txt)))
12657 (insert 12751 (insert
12658 (format 12752 (format
12659 (if todo 12753 (if todo
12660 "<li><a href=\"#sec-%d\"><span class=\"todo\">%s</span></a>\n" 12754 "</li>\n<li><a href=\"#sec-%d\"><span class=\"todo\">%s</span></a>"
12661 "<li><a href=\"#sec-%d\">%s</a>\n") 12755 "</li>\n<li><a href=\"#sec-%d\">%s</a>")
12662 head-count txt)) 12756 head-count txt))
12663 12757
12664 (setq org-last-level level)) 12758 (setq org-last-level level))
12665 ))) 12759 )))
12666 line) 12760 line)
12667 lines)) 12761 lines))
12668 (while (> org-last-level 0) 12762 (while (> org-last-level 0)
12669 (setq org-last-level (1- org-last-level)) 12763 (setq org-last-level (1- org-last-level))
12670 (insert "</ul>\n")) 12764 (insert "</li>\n</ul>\n"))
12671 )) 12765 ))
12672 (setq head-count 0) 12766 (setq head-count 0)
12673 (org-init-section-numbers) 12767 (org-init-section-numbers)
12674 12768
12675 (while (setq line (pop lines) origline line) 12769 (while (setq line (pop lines) origline line)
12756 (abs-p (file-name-absolute-p filename)) 12850 (abs-p (file-name-absolute-p filename))
12757 thefile file-is-image-p search) 12851 thefile file-is-image-p search)
12758 (save-match-data 12852 (save-match-data
12759 (if (string-match "::\\(.*\\)" filename) 12853 (if (string-match "::\\(.*\\)" filename)
12760 (setq search (match-string 1 filename) 12854 (setq search (match-string 1 filename)
12761 filename (replace-match "" nil nil filename))) 12855 filename (replace-match "" t nil filename)))
12762 (setq file-is-image-p 12856 (setq file-is-image-p
12763 (string-match (org-image-file-name-regexp) filename)) 12857 (string-match (org-image-file-name-regexp) filename))
12764 (setq thefile (if abs-p (expand-file-name filename) filename)) 12858 (setq thefile (if abs-p (expand-file-name filename) filename))
12765 (when (and org-export-html-link-org-files-as-html 12859 (when (and org-export-html-link-org-files-as-html
12766 (string-match "\\.org$" thefile)) 12860 (string-match "\\.org$" thefile))
12795 (if (and (string-match org-todo-line-regexp line) 12889 (if (and (string-match org-todo-line-regexp line)
12796 (match-beginning 2)) 12890 (match-beginning 2))
12797 (if (equal (match-string 2 line) org-done-string) 12891 (if (equal (match-string 2 line) org-done-string)
12798 (setq line (replace-match 12892 (setq line (replace-match
12799 "<span class=\"done\">\\2</span>" 12893 "<span class=\"done\">\\2</span>"
12800 nil nil line 2)) 12894 t nil line 2))
12801 (setq line (replace-match "<span class=\"todo\">\\2</span>" 12895 (setq line (replace-match "<span class=\"todo\">\\2</span>"
12802 nil nil line 2)))) 12896 t nil line 2))))
12803 12897
12804 (cond 12898 (cond
12805 ((string-match "^\\(\\*+\\)[ \t]*\\(.*\\)" line) 12899 ((string-match "^\\(\\*+\\)[ \t]*\\(.*\\)" line)
12806 ;; This is a headline 12900 ;; This is a headline
12807 (setq level (org-tr-level (- (match-end 1) (match-beginning 1))) 12901 (setq level (org-tr-level (- (match-end 1) (match-beginning 1)))
12810 (setq txt (replace-match "" t t txt))) 12904 (setq txt (replace-match "" t t txt)))
12811 (if (<= level umax) (setq head-count (+ head-count 1))) 12905 (if (<= level umax) (setq head-count (+ head-count 1)))
12812 (when in-local-list 12906 (when in-local-list
12813 ;; Close any local lists before inserting a new header line 12907 ;; Close any local lists before inserting a new header line
12814 (while local-list-num 12908 (while local-list-num
12909 (org-close-li)
12815 (insert (if (car local-list-num) "</ol>\n" "</ul>")) 12910 (insert (if (car local-list-num) "</ol>\n" "</ul>"))
12816 (pop local-list-num)) 12911 (pop local-list-num))
12817 (setq local-list-indent nil 12912 (setq local-list-indent nil
12818 in-local-list nil)) 12913 in-local-list nil))
12819 (org-html-level-start level txt umax 12914 (org-html-level-start level txt umax
12836 (not (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" 12931 (not (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)"
12837 (car lines)))) 12932 (car lines))))
12838 (setq table-open nil 12933 (setq table-open nil
12839 table-buffer (nreverse table-buffer) 12934 table-buffer (nreverse table-buffer)
12840 table-orig-buffer (nreverse table-orig-buffer)) 12935 table-orig-buffer (nreverse table-orig-buffer))
12936 (org-close-par-maybe)
12841 (insert (org-format-table-html table-buffer table-orig-buffer)))) 12937 (insert (org-format-table-html table-buffer table-orig-buffer))))
12842 (t 12938 (t
12843 ;; Normal lines 12939 ;; Normal lines
12844 (when (string-match 12940 (when (string-match
12845 (cond 12941 (cond
12858 (setq ind (1+ (or (car local-list-indent) 1)))) 12954 (setq ind (1+ (or (car local-list-indent) 1))))
12859 (while (and in-local-list 12955 (while (and in-local-list
12860 (or (and (= ind (car local-list-indent)) 12956 (or (and (= ind (car local-list-indent))
12861 (not starter)) 12957 (not starter))
12862 (< ind (car local-list-indent)))) 12958 (< ind (car local-list-indent))))
12959 (org-close-li)
12863 (insert (if (car local-list-num) "</ol>\n" "</ul>")) 12960 (insert (if (car local-list-num) "</ol>\n" "</ul>"))
12864 (pop local-list-num) (pop local-list-indent) 12961 (pop local-list-num) (pop local-list-indent)
12865 (setq in-local-list local-list-indent)) 12962 (setq in-local-list local-list-indent))
12866 (cond 12963 (cond
12867 ((and starter 12964 ((and starter
12868 (or (not in-local-list) 12965 (or (not in-local-list)
12869 (> ind (car local-list-indent)))) 12966 (> ind (car local-list-indent))))
12870 ;; Start new (level of ) list 12967 ;; Start new (level of ) list
12968 (org-close-par-maybe)
12871 (insert (if start-is-num "<ol>\n<li>\n" "<ul>\n<li>\n")) 12969 (insert (if start-is-num "<ol>\n<li>\n" "<ul>\n<li>\n"))
12872 (push start-is-num local-list-num) 12970 (push start-is-num local-list-num)
12873 (push ind local-list-indent) 12971 (push ind local-list-indent)
12874 (setq in-local-list t)) 12972 (setq in-local-list t))
12875 (starter 12973 (starter
12876 ;; continue current list 12974 ;; continue current list
12975 (org-close-li)
12877 (insert "<li>\n"))) 12976 (insert "<li>\n")))
12878 (if (string-match "^[ \t]*\\[\\([X ]\\)\\]" line) 12977 (if (string-match "^[ \t]*\\[\\([X ]\\)\\]" line)
12879 (setq line 12978 (setq line
12880 (replace-match 12979 (replace-match
12881 (if (equal (match-string 1 line) "X") 12980 (if (equal (match-string 1 line) "X")
12884 t t line)))) 12983 t t line))))
12885 12984
12886 ;; Empty lines start a new paragraph. If hand-formatted lists 12985 ;; Empty lines start a new paragraph. If hand-formatted lists
12887 ;; are not fully interpreted, lines starting with "-", "+", "*" 12986 ;; are not fully interpreted, lines starting with "-", "+", "*"
12888 ;; also start a new paragraph. 12987 ;; also start a new paragraph.
12889 (if (string-match "^ [-+*]-\\|^[ \t]*$" line) (insert "<p>")) 12988 (if (string-match "^ [-+*]-\\|^[ \t]*$" line) (org-open-par))
12890 (insert line (if org-export-preserve-breaks "<br>\n" "\n")))) 12989
12891 )) 12990 ;; Check if the line break needs to be conserved
12892 12991 ;; FIXME: document \\ at end of line.
12992 (cond
12993 ((string-match "\\\\\\\\[ \t]*$" line)
12994 (setq line (replace-match "<br/>" t t line)))
12995 (org-export-preserve-breaks
12996 (setq line (concat line "<br/>"))))
12997
12998 (insert line "\n")))))
12999
12893 ;; Properly close all local lists and other lists 13000 ;; Properly close all local lists and other lists
12894 (when inquote (insert "</pre>\n")) 13001 (when inquote (insert "</pre>\n"))
12895 (when in-local-list 13002 (when in-local-list
12896 ;; Close any local lists before inserting a new header line 13003 ;; Close any local lists before inserting a new header line
12897 (while local-list-num 13004 (while local-list-num
12898 (insert (if (car local-list-num) "</ol>\n" "</ul>")) 13005 (org-close-li)
13006 (insert (if (car local-list-num) "</ol>\n" "</ul>\n"))
12899 (pop local-list-num)) 13007 (pop local-list-num))
12900 (setq local-list-indent nil 13008 (setq local-list-indent nil
12901 in-local-list nil)) 13009 in-local-list nil))
12902 (org-html-level-start 1 nil umax 13010 (org-html-level-start 1 nil umax
12903 (and org-export-with-toc (<= level umax)) 13011 (and org-export-with-toc (<= level umax))
12904 head-count) 13012 head-count)
12905 13013
12906 (when (plist-get opt-plist :auto-postamble) 13014 (when (plist-get opt-plist :auto-postamble)
12907 (insert "<p>") 13015 (when author
12908 (if author (insert (concat (nth 1 lang-words) ": " author "\n"))) 13016 (insert "<p class=\"author\"> "
12909 (if email (insert (concat "<a href=\"mailto:" email "\">&lt;" 13017 (nth 1 lang-words) ": " author "\n")
12910 email "&gt;</a>\n"))) 13018 (when email
12911 (if (or author email) (insert "<br>\n")) 13019 (insert "<a href=\"mailto:" email "\">&lt;"
12912 (if (and date time) (insert (concat (nth 2 lang-words) ": " 13020 email "&gt;</a>\n"))
12913 date " " time "<br>\n")))) 13021 (insert "</p>\n"))
13022 (when (and date time)
13023 (insert "<p class=\"date\"> "
13024 (nth 2 lang-words) ": "
13025 date " " time "</p>\n")))
12914 13026
12915 (if org-export-html-with-timestamp 13027 (if org-export-html-with-timestamp
12916 (insert org-export-html-html-helper-timestamp)) 13028 (insert org-export-html-html-helper-timestamp))
12917 (insert (or (plist-get opt-plist :postamble) "")) 13029 (insert (or (plist-get opt-plist :postamble) ""))
12918 (insert "</body>\n</html>\n") 13030 (insert "</body>\n</html>\n")
12919 (normal-mode) 13031 (normal-mode)
13032 ;; remove empty paragraphs and lists
13033 (goto-char (point-min))
13034 (while (re-search-forward "<p>[ \r\n\t]*</p>" nil t)
13035 (replace-match ""))
13036 (goto-char (point-min))
13037 (while (re-search-forward "<li>[ \r\n\t]*</li>\n?" nil t)
13038 (replace-match ""))
12920 (save-buffer) 13039 (save-buffer)
12921 (goto-char (point-min))))) 13040 (goto-char (point-min)))))
12922 13041
12923 (defun org-format-table-html (lines olines) 13042 (defun org-format-table-html (lines olines)
12924 "Find out which HTML converter to use and return the HTML code." 13043 "Find out which HTML converter to use and return the HTML code."
13044 ;; Break the line into fields and store the fields 13163 ;; Break the line into fields and store the fields
13045 (setq fields (org-split-string line "[ \t]*|[ \t]*")) 13164 (setq fields (org-split-string line "[ \t]*|[ \t]*"))
13046 (if field-buffer 13165 (if field-buffer
13047 (setq field-buffer (mapcar 13166 (setq field-buffer (mapcar
13048 (lambda (x) 13167 (lambda (x)
13049 (concat x "<br>" (pop fields))) 13168 (concat x "<br/>" (pop fields)))
13050 field-buffer)) 13169 field-buffer))
13051 (setq field-buffer fields)))) 13170 (setq field-buffer fields))))
13052 (setq html (concat html "</table>\n")) 13171 (setq html (concat html "</table>\n"))
13053 html)) 13172 html))
13054 13173
13088 ;; Line break of line started and ended with time stamp stuff 13207 ;; Line break of line started and ended with time stamp stuff
13089 (if (not r) 13208 (if (not r)
13090 s 13209 s
13091 (setq r (concat r s)) 13210 (setq r (concat r s))
13092 (unless (string-match "\\S-" (concat b s)) 13211 (unless (string-match "\\S-" (concat b s))
13093 (setq r (concat r "@<br>"))) 13212 (setq r (concat r "@<br/>")))
13094 r))) 13213 r)))
13095 13214
13096 (defun org-html-protect (s) 13215 (defun org-html-protect (s)
13097 ;; convert & to &amp;, < to &lt; and > to &gt; 13216 ;; convert & to &amp;, < to &lt; and > to &gt;
13098 (let ((start 0)) 13217 (let ((start 0))
13129 (defun org-html-do-expand (s) 13248 (defun org-html-do-expand (s)
13130 "Apply all active conversions to translate special ASCII to HTML." 13249 "Apply all active conversions to translate special ASCII to HTML."
13131 (setq s (org-html-protect s)) 13250 (setq s (org-html-protect s))
13132 (if org-export-html-expand 13251 (if org-export-html-expand
13133 (while (string-match "@&lt;\\([^&]*\\)&gt;" s) 13252 (while (string-match "@&lt;\\([^&]*\\)&gt;" s)
13134 (setq s (replace-match "<\\1>" nil nil s)))) 13253 (setq s (replace-match "<\\1>" t nil s))))
13135 (if org-export-with-emphasize 13254 (if org-export-with-emphasize
13136 (setq s (org-export-html-convert-emphasize s))) 13255 (setq s (org-export-html-convert-emphasize s)))
13137 (if org-export-with-sub-superscripts 13256 (if org-export-with-sub-superscripts
13138 (setq s (org-export-html-convert-sub-super s))) 13257 (setq s (org-export-html-convert-sub-super s)))
13139 (if org-export-with-TeX-macros 13258 (if org-export-with-TeX-macros
13198 (setq string (replace-match "\\1<b>\\3</b>\\4" t nil string))) 13317 (setq string (replace-match "\\1<b>\\3</b>\\4" t nil string)))
13199 (while (string-match org-underline-re string) 13318 (while (string-match org-underline-re string)
13200 (setq string (replace-match "\\1<u>\\3</u>\\4" t nil string))) 13319 (setq string (replace-match "\\1<u>\\3</u>\\4" t nil string)))
13201 string) 13320 string)
13202 13321
13322 (defvar org-par-open nil)
13323 (defun org-open-par ()
13324 "Insert <p>, but first close previous paragraph if any."
13325 (org-close-par-maybe)
13326 (insert "\n<p>")
13327 (setq org-par-open t))
13328 (defun org-close-par-maybe ()
13329 "Close paragraph if there is one open."
13330 (when org-par-open
13331 (insert "</p>")
13332 (setq org-par-open nil)))
13333 (defun org-close-li ()
13334 "Close <li> if necessary."
13335 (org-close-par-maybe)
13336 (insert "</li>\n"))
13337 ; (when (save-excursion
13338 ; (re-search-backward "</?\\(ul\\|ol\\|li\\|[hH][0-9]\\)>" nil t))
13339 ; (if (member (match-string 0) '("</ul>" "</ol>" "<li>"))
13340 ; (insert "</li>"))))
13341
13203 (defun org-html-level-start (level title umax with-toc head-count) 13342 (defun org-html-level-start (level title umax with-toc head-count)
13204 "Insert a new level in HTML export. 13343 "Insert a new level in HTML export.
13205 When TITLE is nil, just close all open levels." 13344 When TITLE is nil, just close all open levels."
13345 (org-close-par-maybe)
13206 (let ((l (1+ (max level umax)))) 13346 (let ((l (1+ (max level umax))))
13207 (while (<= l org-level-max) 13347 (while (<= l org-level-max)
13208 (if (aref levels-open (1- l)) 13348 (if (aref levels-open (1- l))
13209 (progn 13349 (progn
13210 (org-html-level-close l) 13350 (org-html-level-close l)
13214 ;; If title is nil, this means this function is called to close 13354 ;; If title is nil, this means this function is called to close
13215 ;; all levels, so the rest is done only if title is given 13355 ;; all levels, so the rest is done only if title is given
13216 (if (> level umax) 13356 (if (> level umax)
13217 (progn 13357 (progn
13218 (if (aref levels-open (1- level)) 13358 (if (aref levels-open (1- level))
13219 (insert "<li>" title "<p>\n") 13359 (progn
13360 (org-close-li)
13361 (insert "<li>" title "<br/>\n"))
13220 (aset levels-open (1- level) t) 13362 (aset levels-open (1- level) t)
13221 (insert "<ul><li>" title "<p>\n"))) 13363 (org-close-par-maybe)
13364 (insert "<ul>\n<li>" title "<br/>\n")))
13222 (if org-export-with-section-numbers 13365 (if org-export-with-section-numbers
13223 (setq title (concat (org-section-number level) " " title))) 13366 (setq title (concat (org-section-number level) " " title)))
13224 (setq level (+ level 1)) 13367 (setq level (+ level 1))
13225 (when (string-match "\\(:[a-zA-Z0-9_@:]+:\\)[ \t]*$" title) 13368 (when (string-match "\\(:[a-zA-Z0-9_@:]+:\\)[ \t]*$" title)
13226 (setq title (replace-match 13369 (setq title (replace-match
13233 "&nbsp;") 13376 "&nbsp;")
13234 "</span>")) 13377 "</span>"))
13235 "") 13378 "")
13236 t t title))) 13379 t t title)))
13237 (if with-toc 13380 (if with-toc
13238 (insert (format "\n<H%d><a name=\"sec-%d\">%s</a></H%d>\n" 13381 (insert (format "\n<h%d><a name=\"sec-%d\">%s</a></h%d>\n"
13239 level head-count title level)) 13382 level head-count title level))
13240 (insert (format "\n<H%d>%s</H%d>\n" level title level))))))) 13383 (insert (format "\n<h%d>%s</h%d>\n" level title level)))
13384 (org-open-par)))))
13241 13385
13242 (defun org-html-level-close (&rest args) 13386 (defun org-html-level-close (&rest args)
13243 "Terminate one level in HTML export." 13387 "Terminate one level in HTML export."
13388 (org-close-li)
13244 (insert "</ul>")) 13389 (insert "</ul>"))
13245 13390
13246 ;; Variable holding the vector with section numbers 13391 ;; Variable holding the vector with section numbers
13247 (defvar org-section-numbers (make-vector org-level-max 0)) 13392 (defvar org-section-numbers (make-vector org-level-max 0))
13248 13393
13282 (setq string (concat string (if (not (string= string "")) "." "") 13427 (setq string (concat string (if (not (string= string "")) "." "")
13283 (int-to-string n))) 13428 (int-to-string n)))
13284 (setq idx (1+ idx))) 13429 (setq idx (1+ idx)))
13285 (save-match-data 13430 (save-match-data
13286 (if (string-match "\\`\\([@0]\\.\\)+" string) 13431 (if (string-match "\\`\\([@0]\\.\\)+" string)
13287 (setq string (replace-match "" nil nil string))) 13432 (setq string (replace-match "" t nil string)))
13288 (if (string-match "\\(\\.0\\)+\\'" string) 13433 (if (string-match "\\(\\.0\\)+\\'" string)
13289 (setq string (replace-match "" nil nil string)))) 13434 (setq string (replace-match "" t nil string))))
13290 string)) 13435 string))
13291 13436
13292 13437
13293 (defun org-export-icalendar-this-file () 13438 (defun org-export-icalendar-this-file ()
13294 "Export current file as an iCalendar file. 13439 "Export current file as an iCalendar file.
14280 (message "\"Org\"-menu now contains full customization menu")) 14425 (message "\"Org\"-menu now contains full customization menu"))
14281 (error "Cannot expand menu (outdated version of cus-edit.el)"))) 14426 (error "Cannot expand menu (outdated version of cus-edit.el)")))
14282 14427
14283 ;;; Miscellaneous stuff 14428 ;;; Miscellaneous stuff
14284 14429
14430 (defun org-context ()
14431 "Return a list of contexts of the current cursor position.
14432 If several contexts apply, all are returned.
14433 Each context entry is a list with a symbol naming the context, and
14434 two positions indicating start and end of the context. Possible
14435 contexts are:
14436
14437 :headline anywhere in a headline
14438 :headline-stars on the leading stars in a headline
14439 :todo-keyword on a TODO keyword (including DONE) in a headline
14440 :tags on the TAGS in a headline
14441 :priority on the priority cookie in a headline
14442 :item on the first line of a plain list item
14443 :checkbox on the checkbox in a plain list item
14444 :table in an org-mode table
14445 :table-special on a special filed in a table
14446 :table-table in a table.el table
14447 :link on a hyperline
14448 :keyword on a keyword: SCHEDULED, DEADLINE, CLOSE,COMMENT, QUOTE.
14449 :target on a <<target>>
14450 :radio-target on a <<<radio-target>>>
14451
14452 This function expects the position to be visible because it uses font-lock
14453 faces as a help to recognize the following contexts: :table-special, :link,
14454 and :keyword."
14455 (let* ((f (get-text-property (point) 'face))
14456 (faces (if (listp f) f (list f)))
14457 (p (point)) clist)
14458 ;; First the large context
14459 (cond
14460 ((org-on-heading-p)
14461 (push (list :headline (point-at-bol) (point-at-eol)) clist)
14462 (when (progn
14463 (beginning-of-line 1)
14464 (looking-at org-todo-line-tags-regexp))
14465 (push (org-point-in-group p 1 :headline-stars) clist)
14466 (push (org-point-in-group p 2 :todo-keyword) clist)
14467 (push (org-point-in-group p 4 :tags) clist))
14468 (goto-char p)
14469 (skip-chars-backward "^[\n\r \t") (or (eobp) (backward-char 1))
14470 (if (looking-at "\\[#[A-Z]\\]")
14471 (push (org-point-in-group p 0 :priority) clist)))
14472
14473 ((org-at-item-p)
14474 (push (list :item (point-at-bol)
14475 (save-excursion (org-end-of-item) (point)))
14476 clist)
14477 (and (org-at-item-checkbox-p)
14478 (push (org-point-in-group p 0 :checkbox) clist)))
14479
14480 ((org-at-table-p)
14481 (push (list :table (org-table-begin) (org-table-end)) clist)
14482 (if (memq 'org-formula faces)
14483 (push (list :table-special
14484 (previous-single-property-change p 'face)
14485 (next-single-property-change p 'face)) clist)))
14486 ((org-at-table-p 'any)
14487 (push (list :table-table) clist)))
14488 (goto-char p)
14489
14490 ;; Now the small context
14491 (cond
14492 ((org-at-timestamp-p)
14493 (push (org-point-in-group p 0 :timestamp) clist))
14494 ((memq 'org-link faces)
14495 (push (list :link
14496 (previous-single-property-change p 'face)
14497 (next-single-property-change p 'face)) clist))
14498 ((memq 'org-special-keyword faces)
14499 (push (list :keyword
14500 (previous-single-property-change p 'face)
14501 (next-single-property-change p 'face)) clist))
14502 ((org-on-target-p)
14503 (push (org-point-in-group p 0 :target) clist)
14504 (goto-char (1- (match-beginning 0)))
14505 (if (looking-at org-radio-target-regexp)
14506 (push (org-point-in-group p 0 :radio-target) clist))
14507 (goto-char p)))
14508
14509 (setq clist (nreverse (delq nil clist)))
14510 clist))
14511
14512 (defun org-point-in-group (point group &optional context)
14513 "Check if POINT is in match-group GROUP.
14514 If CONTEXT is non-nil, return a list with CONTEXT and the boundaries of the
14515 match. If the match group does ot exist or point is not inside it,
14516 return nil."
14517 (and (match-beginning group)
14518 (>= point (match-beginning group))
14519 (<= point (match-end group))
14520 (if context
14521 (list context (match-beginning group) (match-end group))
14522 t)))
14523
14285 (defun org-move-line-down (arg) 14524 (defun org-move-line-down (arg)
14286 "Move the current line down. With prefix argument, move it past ARG lines." 14525 "Move the current line down. With prefix argument, move it past ARG lines."
14287 (interactive "p") 14526 (interactive "p")
14288 (let ((col (current-column)) 14527 (let ((col (current-column))
14289 beg end pos) 14528 beg end pos)
14645 14884
14646 (provide 'org) 14885 (provide 'org)
14647 14886
14648 (run-hooks 'org-load-hook) 14887 (run-hooks 'org-load-hook)
14649 14888
14889
14650 ;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd 14890 ;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd
14651 ;;; org.el ends here 14891 ;;; org.el ends here
14892