comparison lisp/textmodes/org.el @ 65243:d0087dcb8981

(org-special-keyword): New face. (org-table-copy-down, org-table-eval-formula) (org-table-recalculate, org-init-section-numbers): Use `string-to-number' instead of `string-to-int'. (org-get-location): Use `insert-buffer-substring' instead of `insert-buffer'. (org-modify-diary-entry-string): New function. (org-get-entries-from-diary): Set the hook for `add-to-diary-list'. (org-disable-agenda-to-diary): renamed from `org-disable-diary'. (org-toggle-fixed-width-section): Use QUOTE keyword if there is no active region. (org-export-as-html): Handle QUOTE keyword. (org-quote-string): New option. (org-bookmark-jump-unhide): New function, used for `bookmark-after-jump-hook'. (org-diary-default-entry): Apply only when not called through `org-agenda'.
author Carsten Dominik <dominik@science.uva.nl>
date Tue, 30 Aug 2005 12:06:14 +0000
parents 5b1a238fcbb4
children a95981ee377b
comparison
equal deleted inserted replaced
65242:5ebb62612b85 65243:d0087dcb8981
1 ;; org.el --- Outline-based notes management and organizer 1 ;;; org.el --- Outline-based notes management and organizer
2 ;; Carstens outline-mode for keeping track of everything. 2 ;; Carstens outline-mode for keeping track of everything.
3 3 ;; Copyright (c) 2004, 2005 Free Software Foundation
4 ;; Copyright (C) 2004, 2005 Free Software Foundation, Inc.
5 ;; 4 ;;
6 ;; Author: Carsten Dominik <dominik at science dot uva dot nl> 5 ;; Author: Carsten Dominik <dominik at science dot uva dot nl>
7 ;; Keywords: outlines, hypermedia, calendar 6 ;; Keywords: outlines, hypermedia, calendar
8 ;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/ 7 ;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/
9 ;; Version: 3.14 8 ;; Version: 3.15
10 ;; 9 ;;
11 ;; This file is part of GNU Emacs. 10 ;; This file is part of GNU Emacs.
12 ;; 11 ;;
13 ;; 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
14 ;; 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 ;; Org-mode, you can read the same text online as HTML. There is also an 78 ;; Org-mode, you can read the same text online as HTML. There is also an
80 ;; excellent reference card made by Philip Rooke. 79 ;; excellent reference card made by Philip Rooke.
81 ;; 80 ;;
82 ;; Changes: 81 ;; Changes:
83 ;; ------- 82 ;; -------
83 ;; Version 3.15
84 ;; - QUOTE keyword at the beginning of an entry causes fixed-width export
85 ;; of unmodified entry text. `C-c :' toggles this keyword.
86 ;; - New face `org-special-keyword' which is used for COMMENT, QUOTE,
87 ;; DEADLINE and SCHEDULED, and priority cookies. Default is only a weak
88 ;; color, to reduce the amount of aggressive color in the buffer.
89 ;;
84 ;; Version 3.14 90 ;; Version 3.14
85 ;; - Formulas for individual fields in table. 91 ;; - Formulas for individual fields in table.
86 ;; - Automatic recalculation in calculating tables. 92 ;; - Automatic recalculation in calculating tables.
87 ;; - Named fields and columns in tables. 93 ;; - Named fields and columns in tables.
88 ;; - Fixed bug with calling `org-archive' several times in a row. 94 ;; - Fixed bug with calling `org-archive' several times in a row.
187 (require 'time-date) 193 (require 'time-date)
188 (require 'easymenu) 194 (require 'easymenu)
189 195
190 ;;; Customization variables 196 ;;; Customization variables
191 197
192 (defvar org-version "3.14" 198 (defvar org-version "3.15"
193 "The version number of the file org.el.") 199 "The version number of the file org.el.")
194 (defun org-version () 200 (defun org-version ()
195 (interactive) 201 (interactive)
196 (message "Org-mode version %s" org-version)) 202 (message "Org-mode version %s" org-version))
197 203
383 (defcustom org-comment-string "COMMENT" 389 (defcustom org-comment-string "COMMENT"
384 "Entries starting with this keyword will never be exported. 390 "Entries starting with this keyword will never be exported.
385 An entry can be toggled between COMMENT and normal with 391 An entry can be toggled between COMMENT and normal with
386 \\[org-toggle-comment]. 392 \\[org-toggle-comment].
387 Changes become only effective after restarting Emacs." 393 Changes become only effective after restarting Emacs."
394 :group 'org-keywords
395 :type 'string)
396
397 (defcustom org-quote-string "QUOTE"
398 "Entries starting with this keyword will be exported in fixed-width font.
399 Quoting applies only to the text in the entry following the headline, and does
400 not extend beyond the next headline, even if that is lower level.
401 An entry can be toggled between QUOTE and normal with
402 \\[org-toggle-fixed-width-section]"
388 :group 'org-keywords 403 :group 'org-keywords
389 :type 'string) 404 :type 'string)
390 405
391 (defcustom org-after-todo-state-change-hook nil 406 (defcustom org-after-todo-state-change-hook nil
392 "Hook which is run after the state of a TODO item was changed. 407 "Hook which is run after the state of a TODO item was changed.
1591 (((class color) (background dark)) (:foreground "LightSalmon")) 1606 (((class color) (background dark)) (:foreground "LightSalmon"))
1592 (t (:italic t))) 1607 (t (:italic t)))
1593 "Face used for level 8 headlines." 1608 "Face used for level 8 headlines."
1594 :group 'org-faces) 1609 :group 'org-faces)
1595 1610
1611 (defface org-special-keyword ;; font-lock-string-face
1612 '((((type tty) (class color)) (:foreground "green"))
1613 (((class color) (background light)) (:foreground "RosyBrown"))
1614 (((class color) (background dark)) (:foreground "LightSalmon"))
1615 (t (:italic t)))
1616 "Face used for level 8 headlines."
1617 :group 'org-faces)
1618
1596 (defface org-warning ;; font-lock-warning-face 1619 (defface org-warning ;; font-lock-warning-face
1597 '((((type tty) (class color)) (:foreground "red")) 1620 '((((type tty) (class color)) (:foreground "red"))
1598 (((class color) (background light)) (:foreground "Red" :bold t)) 1621 (((class color) (background light)) (:foreground "Red" :bold t))
1599 (((class color) (background dark)) (:foreground "Red1" :bold t)) 1622 (((class color) (background dark)) (:foreground "Red1" :bold t))
1600 ; (((class color) (background dark)) (:foreground "Pink" :bold t)) 1623 ; (((class color) (background dark)) (:foreground "Pink" :bold t))
1917 (list 1940 (list
1918 '(org-activate-links (0 'org-link)) 1941 '(org-activate-links (0 'org-link))
1919 '(org-activate-dates (0 'org-link)) 1942 '(org-activate-dates (0 'org-link))
1920 (list (concat "^\\*+[ \t]*" org-not-done-regexp) 1943 (list (concat "^\\*+[ \t]*" org-not-done-regexp)
1921 '(1 'org-warning t)) 1944 '(1 'org-warning t))
1922 (list (concat "\\[#[A-Z]\\]") '(0 'org-warning t)) 1945 (list (concat "\\[#[A-Z]\\]") '(0 'org-special-keyword t))
1923 (list (concat "\\<" org-deadline-string) '(0 'org-warning t)) 1946 ; (list (concat "\\<" org-deadline-string) '(0 'org-warning t))
1924 (list (concat "\\<" org-scheduled-string) '(0 'org-warning t)) 1947 ; (list (concat "\\<" org-scheduled-string) '(0 'org-warning t))
1948 (list (concat "\\<" org-deadline-string) '(0 'org-special-keyword t))
1949 (list (concat "\\<" org-scheduled-string) '(0 'org-special-keyword t))
1925 ;; '("\\(\\s-\\|^\\)\\(\\*\\([a-zA-Z]+\\)\\*\\)\\([^a-zA-Z*]\\|$\\)" 1950 ;; '("\\(\\s-\\|^\\)\\(\\*\\([a-zA-Z]+\\)\\*\\)\\([^a-zA-Z*]\\|$\\)"
1926 ;; (3 'bold)) 1951 ;; (3 'bold))
1927 ;; '("\\(\\s-\\|^\\)\\(/\\([a-zA-Z]+\\)/\\)\\([^a-zA-Z*]\\|$\\)" 1952 ;; '("\\(\\s-\\|^\\)\\(/\\([a-zA-Z]+\\)/\\)\\([^a-zA-Z*]\\|$\\)"
1928 ;; (3 'italic)) 1953 ;; (3 'italic))
1929 ;; '("\\(\\s-\\|^\\)\\(_\\([a-zA-Z]+\\)_\\)\\([^a-zA-Z*]\\|$\\)" 1954 ;; '("\\(\\s-\\|^\\)\\(_\\([a-zA-Z]+\\)_\\)\\([^a-zA-Z*]\\|$\\)"
1930 ;; (3 'underline)) 1955 ;; (3 'underline))
1931 (list (concat "^\\*+[ \t]*\\<\\(" org-comment-string "\\)\\>") 1956 ; (list (concat "^\\*+[ \t]*\\<\\(" org-comment-string "\\)\\>")
1932 '(1 'org-warning t)) 1957 ; '(1 'org-warning t))
1958 (list (concat "^\\*+[ \t]*\\<\\(" org-comment-string
1959 "\\|" org-quote-string "\\)\\>")
1960 '(1 'org-special-keyword t))
1933 '("^#.*" (0 'font-lock-comment-face t)) 1961 '("^#.*" (0 'font-lock-comment-face t))
1934 (if org-fontify-done-headline 1962 (if org-fontify-done-headline
1935 (list (concat "^[*]+ +\\<\\(" org-done-string "\\)\\(.*\\)\\>") 1963 (list (concat "^[*]+ +\\<\\(" org-done-string "\\)\\(.*\\)\\>")
1936 '(1 'org-done t) '(2 'org-headline-done t)) 1964 '(1 'org-done t) '(2 'org-headline-done t))
1937 (list (concat "^[*]+ +\\<\\(" org-done-string "\\)\\>") 1965 (list (concat "^[*]+ +\\<\\(" org-done-string "\\)\\>")
2214 (with-output-to-temp-buffer "*Help*" 2242 (with-output-to-temp-buffer "*Help*"
2215 (princ help)) 2243 (princ help))
2216 (shrink-window-if-larger-than-buffer (get-buffer-window "*Help*")) 2244 (shrink-window-if-larger-than-buffer (get-buffer-window "*Help*"))
2217 (setq buffer-read-only nil) 2245 (setq buffer-read-only nil)
2218 (erase-buffer) 2246 (erase-buffer)
2219 (insert-buffer buf) 2247 (insert-buffer-substring buf)
2220 (let ((org-startup-truncated t) 2248 (let ((org-startup-truncated t)
2221 (org-startup-folded t) 2249 (org-startup-folded t)
2222 (org-startup-with-deadline-check nil)) 2250 (org-startup-with-deadline-check nil))
2223 (org-mode)) 2251 (org-mode))
2224 (setq buffer-read-only t) 2252 (setq buffer-read-only t)
4011 (and (eolp) (not (bolp)) (backward-char 1)) 4039 (and (eolp) (not (bolp)) (backward-char 1))
4012 (if (and org-agenda-follow-mode 4040 (if (and org-agenda-follow-mode
4013 (get-text-property (point) 'org-marker)) 4041 (get-text-property (point) 'org-marker))
4014 (org-agenda-show))) 4042 (org-agenda-show)))
4015 4043
4016 (defvar org-disable-diary nil) ;Dynamically-scoped param. 4044 (defvar org-disable-agenda-to-diary nil) ;Dynamically-scoped param.
4017 4045
4018 (defun org-get-entries-from-diary (date) 4046 (defun org-get-entries-from-diary (date)
4019 "Get the (Emacs Calendar) diary entries for DATE." 4047 "Get the (Emacs Calendar) diary entries for DATE."
4020 (let* ((fancy-diary-buffer "*temporary-fancy-diary-buffer*") 4048 (let* ((fancy-diary-buffer "*temporary-fancy-diary-buffer*")
4021 (diary-display-hook '(fancy-diary-display)) 4049 (diary-display-hook '(fancy-diary-display))
4022 (list-diary-entries-hook 4050 (list-diary-entries-hook
4023 (cons 'org-diary-default-entry list-diary-entries-hook)) 4051 (cons 'org-diary-default-entry list-diary-entries-hook))
4052 (diary-file-name-prefix-function nil) ; turn this feature off
4053 (diary-modify-entry-list-string-function 'org-modify-diary-entry-string)
4024 entries 4054 entries
4025 (org-disable-diary t)) 4055 (org-disable-agenda-to-diary t))
4026 (save-excursion 4056 (save-excursion
4027 (save-window-excursion 4057 (save-window-excursion
4028 (list-diary-entries date 1))) 4058 (list-diary-entries date 1)))
4029 (if (not (get-buffer fancy-diary-buffer)) 4059 (if (not (get-buffer fancy-diary-buffer))
4030 (setq entries nil) 4060 (setq entries nil)
4074 (replace-match "")) 4104 (replace-match ""))
4075 (goto-char (point-min)) 4105 (goto-char (point-min))
4076 (if (re-search-forward "^Org-mode dummy\n?" nil t) 4106 (if (re-search-forward "^Org-mode dummy\n?" nil t)
4077 (replace-match ""))) 4107 (replace-match "")))
4078 4108
4079 ;; Advise the add-to-diary-list function to allow org to jump to 4109 ;; Make sure entries from the diary have the right text properties.
4080 ;; diary entries. Wrapped into eval-after-load to avoid loading
4081 ;; advice unnecessarily
4082 (eval-after-load "diary-lib" 4110 (eval-after-load "diary-lib"
4083 '(defadvice add-to-diary-list (before org-mark-diary-entry activate) 4111 '(if (boundp 'diary-modify-entry-list-string-function)
4084 "Make the position visible." 4112 ;; We can rely on the hook, nothing to do
4085 (if (and org-disable-diary ;; called from org-agenda 4113 nil
4086 (stringp string) 4114 ;; Hook not avaiable, must use advice to make this work
4087 (buffer-file-name)) 4115 (defadvice add-to-diary-list (before org-mark-diary-entry activate)
4088 (add-text-properties 4116 "Make the position visible."
4089 0 (length string) 4117 (if (and org-disable-agenda-to-diary ;; called from org-agenda
4090 (list 'mouse-face 'highlight 4118 (stringp string)
4091 'keymap org-agenda-keymap 4119 (buffer-file-name))
4092 'help-echo 4120 (setq string (org-modify-diary-entry-string string))))))
4093 (format 4121
4094 "mouse-2 or RET jump to diary file %s" 4122 (defun org-modify-diary-entry-string (string)
4095 (abbreviate-file-name (buffer-file-name))) 4123 "Add text properties to string, allowing org-mode to act on it."
4096 'org-agenda-diary-link t 4124 (add-text-properties
4097 'org-marker (org-agenda-new-marker (point-at-bol))) 4125 0 (length string)
4098 string)))) 4126 (list 'mouse-face 'highlight
4127 'keymap org-agenda-keymap
4128 'help-echo
4129 (format
4130 "mouse-2 or RET jump to diary file %s"
4131 (abbreviate-file-name (buffer-file-name)))
4132 'org-agenda-diary-link t
4133 'org-marker (org-agenda-new-marker (point-at-bol)))
4134 string)
4135 string)
4099 4136
4100 (defun org-diary-default-entry () 4137 (defun org-diary-default-entry ()
4101 "Add a dummy entry to the diary. 4138 "Add a dummy entry to the diary.
4102 Needed to avoid empty dates which mess up holiday display." 4139 Needed to avoid empty dates which mess up holiday display."
4103 ;; Catch the error if dealing with the new add-to-diary-alist 4140 ;; Catch the error if dealing with the new add-to-diary-alist
4104 (condition-case nil 4141 (when org-disable-agenda-to-diary
4105 (add-to-diary-list original-date "Org-mode dummy" "") 4142 (condition-case nil
4106 (error 4143 (add-to-diary-list original-date "Org-mode dummy" "")
4107 (add-to-diary-list original-date "Org-mode dummy" "" nil)))) 4144 (error
4145 (add-to-diary-list original-date "Org-mode dummy" "" nil)))))
4108 4146
4109 (defun org-add-file (&optional file) 4147 (defun org-add-file (&optional file)
4110 "Add current file to the list of files in variable `org-agenda-files'. 4148 "Add current file to the list of files in variable `org-agenda-files'.
4111 These are the files which are being checked for agenda entries. 4149 These are the files which are being checked for agenda entries.
4112 Optional argument FILE means, use this file instead of the current. 4150 Optional argument FILE means, use this file instead of the current.
4236 (list entry) 4274 (list entry)
4237 org-agenda-files)) 4275 org-agenda-files))
4238 file rtn results) 4276 file rtn results)
4239 ;; If this is called during org-agenda, don't return any entries to 4277 ;; If this is called during org-agenda, don't return any entries to
4240 ;; the calendar. Org Agenda will list these entries itself. 4278 ;; the calendar. Org Agenda will list these entries itself.
4241 (if org-disable-diary (setq files nil)) 4279 (if org-disable-agenda-to-diary (setq files nil))
4242 (while (setq file (pop files)) 4280 (while (setq file (pop files))
4243 (setq rtn (apply 'org-agenda-get-day-entries file date args)) 4281 (setq rtn (apply 'org-agenda-get-day-entries file date args))
4244 (setq results (append results rtn))) 4282 (setq results (append results rtn)))
4245 (concat (org-finalize-agenda-entries results) "\n"))) 4283 (if results
4284 (concat (org-finalize-agenda-entries results) "\n"))))
4246 4285
4247 (defun org-agenda-get-day-entries (file date &rest args) 4286 (defun org-agenda-get-day-entries (file date &rest args)
4248 "Does the work for `org-diary' and `org-agenda'. 4287 "Does the work for `org-diary' and `org-agenda'.
4249 FILE is the path to a file to be checked for entries. DATE is date like 4288 FILE is the path to a file to be checked for entries. DATE is date like
4250 the one returned by `calendar-current-date'. ARGS are symbols indicating 4289 the one returned by `calendar-current-date'. ARGS are symbols indicating
6268 (throw 'exit (match-string 1)))))))) 6307 (throw 'exit (match-string 1))))))))
6269 (if txt 6308 (if txt
6270 (progn 6309 (progn
6271 (if (and org-table-copy-increment 6310 (if (and org-table-copy-increment
6272 (string-match "^[0-9]+$" txt)) 6311 (string-match "^[0-9]+$" txt))
6273 (setq txt (format "%d" (+ (string-to-int txt) 1)))) 6312 (setq txt (format "%d" (+ (string-to-number txt) 1))))
6274 (insert txt) 6313 (insert txt)
6275 (org-table-maybe-recalculate-line) 6314 (org-table-maybe-recalculate-line)
6276 (org-table-align)) 6315 (org-table-align))
6277 (error "No non-empty field found")))) 6316 (error "No non-empty field found"))))
6278 6317
6995 (* 1.0 (+ h (/ m 60.0) (/ s 3600.0))))) 7034 (* 1.0 (+ h (/ m 60.0) (/ s 3600.0)))))
6996 ((equal n 0) nil) 7035 ((equal n 0) nil)
6997 (t n)))) 7036 (t n))))
6998 7037
6999 (defun org-table-get-vertical-vector (desc &optional tbeg col) 7038 (defun org-table-get-vertical-vector (desc &optional tbeg col)
7000 "Get a calc vector from a column, according to descriptor DESC. 7039 "Get a calc vector from a column, accorting to desctiptor DESC.
7001 Optional arguments TBEG and COL can give the beginning of the table 7040 Optional arguments TBEG and COL can give the beginning of the table and
7002 and the current column, to avoid unnecessary parsing." 7041 the current column, to avoid unnecessary parsing."
7003 (save-excursion 7042 (save-excursion
7004 (or tbeg (setq tbeg (org-table-begin))) 7043 (or tbeg (setq tbeg (org-table-begin)))
7005 (or col (setq col (org-table-current-column))) 7044 (or col (setq col (org-table-current-column)))
7006 (let (beg end nn n n1 n2 l (thisline (org-current-line)) hline-list) 7045 (let (beg end nn n n1 n2 l (thisline (org-current-line)) hline-list)
7007 (cond 7046 (cond
7045 (lambda (x) (setq x (org-trim x)) 7084 (lambda (x) (setq x (org-trim x))
7046 (if (equal x "") "0" x)) 7085 (if (equal x "") "0" x))
7047 l ",") "]")) 7086 l ",") "]"))
7048 ((string-match "\\([0-9]+\\)" desc) 7087 ((string-match "\\([0-9]+\\)" desc)
7049 (beginning-of-line 1) 7088 (beginning-of-line 1)
7050 (when (re-search-backward org-table-dataline-regexp tbeg t 7089 (when (re-search-backward org-table-dataline-regexp tbeg t
7051 (string-to-number (match-string 0 desc))) 7090 (string-to-number (match-string 0 desc)))
7052 (org-table-goto-column col) 7091 (org-table-goto-column col)
7053 (org-trim (org-table-get-field)))))))) 7092 (org-trim (org-table-get-field))))))))
7054 7093
7055 (defvar org-table-formula-history nil) 7094 (defvar org-table-formula-history nil)
7141 (defun org-table-modify-formulas (action &rest columns) 7180 (defun org-table-modify-formulas (action &rest columns)
7142 "Modify the formulas stored below the current table. 7181 "Modify the formulas stored below the current table.
7143 ACTION can be `remove', `insert', `swap'. For `swap', two column numbers are 7182 ACTION can be `remove', `insert', `swap'. For `swap', two column numbers are
7144 expected, for the other action only a single column number is needed." 7183 expected, for the other action only a single column number is needed."
7145 (let ((list (org-table-get-stored-formulas)) 7184 (let ((list (org-table-get-stored-formulas))
7146 (nmax (length (org-split-string 7185 (nmax (length (org-split-string
7147 (buffer-substring (point-at-bol) (point-at-eol)) 7186 (buffer-substring (point-at-bol) (point-at-eol))
7148 "|"))) 7187 "|")))
7149 col col1 col2 scol si sc1 sc2) 7188 col col1 col2 scol si sc1 sc2)
7150 (cond 7189 (cond
7151 ((null list)) ; No action needed if there are no stored formulas 7190 ((null list)) ; No action needed if there are no stored formulas
7220 (while (re-search-forward "^[ \t]*| *\\([_^]\\) *\\(|.*\\)" end t) 7259 (while (re-search-forward "^[ \t]*| *\\([_^]\\) *\\(|.*\\)" end t)
7221 (setq c (match-string 1) 7260 (setq c (match-string 1)
7222 fields (org-split-string (match-string 2) " *| *")) 7261 fields (org-split-string (match-string 2) " *| *"))
7223 (save-excursion 7262 (save-excursion
7224 (beginning-of-line (if (equal c "_") 2 0)) 7263 (beginning-of-line (if (equal c "_") 2 0))
7225 (setq line (org-current-line) col 1) 7264 (setq line (org-current-line) col 1)
7226 (and (looking-at "^[ \t]*|[^|]*\\(|.*\\)") 7265 (and (looking-at "^[ \t]*|[^|]*\\(|.*\\)")
7227 (setq fields1 (org-split-string (match-string 1) " *| *")))) 7266 (setq fields1 (org-split-string (match-string 1) " *| *"))))
7228 (while (and fields1 (setq field (pop fields))) 7267 (while (and fields1 (setq field (pop fields)))
7229 (setq v (pop fields1) col (1+ col)) 7268 (setq v (pop fields1) col (1+ col))
7230 (when (and (stringp field) (stringp v) 7269 (when (and (stringp field) (stringp v)
7438 (setq ndown (1- ndown)) 7477 (setq ndown (1- ndown))
7439 (setq form (copy-sequence formula)) 7478 (setq form (copy-sequence formula))
7440 ;; Insert the references to fields in same row 7479 ;; Insert the references to fields in same row
7441 (while (string-match "\\$\\([0-9]+\\)?" form) 7480 (while (string-match "\\$\\([0-9]+\\)?" form)
7442 (setq n (if (match-beginning 1) 7481 (setq n (if (match-beginning 1)
7443 (string-to-int (match-string 1 form)) 7482 (string-to-number (match-string 1 form))
7444 n0) 7483 n0)
7445 x (nth (1- n) fields)) 7484 x (nth (1- n) fields))
7446 (unless x (error "Invalid field specifier \"%s\"" 7485 (unless x (error "Invalid field specifier \"%s\""
7447 (match-string 0 form))) 7486 (match-string 0 form)))
7448 (if (equal x "") (setq x "0")) 7487 (if (equal x "") (setq x "0"))
7537 (setq cnt (1+ cnt)))) 7576 (setq cnt (1+ cnt))))
7538 (setq org-last-recalc-line (org-current-line)) 7577 (setq org-last-recalc-line (org-current-line))
7539 (setq eql eqlnum) 7578 (setq eql eqlnum)
7540 (while (setq entry (pop eql)) 7579 (while (setq entry (pop eql))
7541 (goto-line org-last-recalc-line) 7580 (goto-line org-last-recalc-line)
7542 (org-table-goto-column (string-to-int (car entry)) nil 'force) 7581 (org-table-goto-column (string-to-number (car entry)) nil 'force)
7543 (org-table-eval-formula nil (cdr entry) 'noalign 'nocst 'nostore)))) 7582 (org-table-eval-formula nil (cdr entry) 'noalign 'nocst 'nostore))))
7544 (goto-line thisline) 7583 (goto-line thisline)
7545 (org-table-goto-column thiscol) 7584 (org-table-goto-column thiscol)
7546 (or noalign (and org-table-may-need-update (org-table-align)) 7585 (or noalign (and org-table-may-need-update (org-table-align))
7547 (and all (message "Re-applying formulas to %d lines...done" cnt))) 7586 (and all (message "Re-applying formulas to %d lines...done" cnt)))
7620 (erase-buffer) 7659 (erase-buffer)
7621 (fundamental-mode) 7660 (fundamental-mode)
7622 (set (make-local-variable 'org-pos) pos) 7661 (set (make-local-variable 'org-pos) pos)
7623 (set (make-local-variable 'org-window-configuration) wc) 7662 (set (make-local-variable 'org-window-configuration) wc)
7624 (use-local-map org-edit-formulas-map) 7663 (use-local-map org-edit-formulas-map)
7625 (setq s "# Edit formulas and finish with `C-c C-c'. 7664 (setq s "# Edit formulas and finish with `C-c C-c'.
7626 # Use `C-u C-c C-c' to also appy them immediately to the entire table. 7665 # Use `C-u C-c C-c' to also appy them immediately to the entire table.
7627 # Use `C-c ?' to get information about $name at point. 7666 # Use `C-c ?' to get information about $name at point.
7628 # To cancel editing, press `C-c C-q'.\n") 7667 # To cancel editing, press `C-c C-q'.\n")
7629 (put-text-property 0 (length s) 'face 'font-lock-comment-face s) 7668 (put-text-property 0 (length s) 'face 'font-lock-comment-face s)
7630 (insert s) 7669 (insert s)
7658 (message "Named field, column %d of line %d" (nth 2 e) (nth 1 e))) 7697 (message "Named field, column %d of line %d" (nth 2 e) (nth 1 e)))
7659 ((setq e (assoc var org-table-column-names)) 7698 ((setq e (assoc var org-table-column-names))
7660 (switch-to-buffer-other-window (marker-buffer pos)) 7699 (switch-to-buffer-other-window (marker-buffer pos))
7661 (goto-char pos) 7700 (goto-char pos)
7662 (goto-char (org-table-begin)) 7701 (goto-char (org-table-begin))
7663 (if (re-search-forward (concat "^[ \t]*| *! *.*?| *\\(" var "\\) *|") 7702 (if (re-search-forward (concat "^[ \t]*| *! *.*?| *\\(" var "\\) *|")
7664 (org-table-end) t) 7703 (org-table-end) t)
7665 (progn 7704 (progn
7666 (goto-char (match-beginning 1)) 7705 (goto-char (match-beginning 1))
7667 (message "Named column (column %s)" (cdr e))) 7706 (message "Named column (column %s)" (cdr e)))
7668 (error "Column name not found")) 7707 (error "Column name not found"))
7713 (unless (org-at-table-p) 7752 (unless (org-at-table-p)
7714 (error "Lost table position - cannot install formulae")) 7753 (error "Lost table position - cannot install formulae"))
7715 (org-table-store-formulas eql) 7754 (org-table-store-formulas eql)
7716 (move-marker pos nil) 7755 (move-marker pos nil)
7717 (kill-buffer "*Edit Formulas*") 7756 (kill-buffer "*Edit Formulas*")
7718 (if arg 7757 (if arg
7719 (org-table-recalculate 'all) 7758 (org-table-recalculate 'all)
7720 (message "New formulas installed - press C-u C-c C-c to apply.")))) 7759 (message "New formulas installed - press C-u C-c C-c to apply."))))
7721 7760
7722 (defun org-abort-edit-formulas () 7761 (defun org-abort-edit-formulas ()
7723 "Abort editing formulas, without installing the changes." 7762 "Abort editing formulas, without installing the changes."
7799 ;; Make sure we are first in minor-mode-map-alist 7838 ;; Make sure we are first in minor-mode-map-alist
7800 (let ((c (assq 'orgtbl-mode minor-mode-map-alist))) 7839 (let ((c (assq 'orgtbl-mode minor-mode-map-alist)))
7801 (and c (setq minor-mode-map-alist 7840 (and c (setq minor-mode-map-alist
7802 (cons c (delq c minor-mode-map-alist))))) 7841 (cons c (delq c minor-mode-map-alist)))))
7803 (set (make-local-variable (quote org-table-may-need-update)) t) 7842 (set (make-local-variable (quote org-table-may-need-update)) t)
7804 (make-local-hook (quote before-change-functions)) 7843 (make-local-hook (quote before-change-functions)) ; needed for XEmacs
7805 (add-hook 'before-change-functions 'org-before-change-function 7844 (add-hook 'before-change-functions 'org-before-change-function
7806 nil 'local) 7845 nil 'local)
7807 (set (make-local-variable 'org-old-auto-fill-inhibit-regexp) 7846 (set (make-local-variable 'org-old-auto-fill-inhibit-regexp)
7808 auto-fill-inhibit-regexp) 7847 auto-fill-inhibit-regexp)
7809 (set (make-local-variable 'auto-fill-inhibit-regexp) 7848 (set (make-local-variable 'auto-fill-inhibit-regexp)
8618 (and (string-match "#\\+CATEGORY" s) 8657 (and (string-match "#\\+CATEGORY" s)
8619 (setq s (substring s 0 (match-beginning 0)))) 8658 (setq s (substring s 0 (match-beginning 0))))
8620 (insert s))) 8659 (insert s)))
8621 8660
8622 (defun org-toggle-fixed-width-section (arg) 8661 (defun org-toggle-fixed-width-section (arg)
8623 "Toggle the fixed-width indicator at the beginning of lines in the region. 8662 "Toggle the fixed-width export.
8624 If there is no active region, only acts on the current line. 8663 If there is no active region, the QUOTE keyword at the current headline is
8625 If the first non-white character in the first line of the region is a 8664 inserted or removed. When present, it causes the text between this headline
8626 vertical bar \"|\", then the command removes the bar from all lines in 8665 and the next to be exported as fixed-width text, and unmodified.
8627 the region. If the first character is not a bar, the command adds a 8666 If there is an active region, this command adds or removes a colon as the
8628 bar to all lines, in the column given by the beginning of the region. 8667 first character of this line. If the first character of a line is a colon,
8629 8668 this line is also exported in fixed-width font."
8630 If there is a numerical prefix ARG, create ARG new lines starting with \"|\"."
8631 (interactive "P") 8669 (interactive "P")
8632 (let* ((cc 0) 8670 (let* ((cc 0)
8633 (regionp (org-region-active-p)) 8671 (regionp (org-region-active-p))
8634 (beg (if regionp (region-beginning) (point))) 8672 (beg (if regionp (region-beginning) (point)))
8635 (end (if regionp (region-end))) 8673 (end (if regionp (region-end)))
8636 (nlines (or arg (if (and beg end) (count-lines beg end) 1))) 8674 (nlines (or arg (if (and beg end) (count-lines beg end) 1)))
8637 (re "[ \t]*\\(:\\)") 8675 (re "[ \t]*\\(:\\)")
8638 off) 8676 off)
8639 (save-excursion 8677 (if regionp
8640 (goto-char beg) 8678 (save-excursion
8641 (setq cc (current-column)) 8679 (goto-char beg)
8642 (beginning-of-line 1) 8680 (setq cc (current-column))
8643 (setq off (looking-at re)) 8681 (beginning-of-line 1)
8644 (while (> nlines 0) 8682 (setq off (looking-at re))
8645 (setq nlines (1- nlines)) 8683 (while (> nlines 0)
8646 (beginning-of-line 1) 8684 (setq nlines (1- nlines))
8647 (cond 8685 (beginning-of-line 1)
8648 (arg 8686 (cond
8649 (move-to-column cc t) 8687 (arg
8650 (insert ":\n") 8688 (move-to-column cc t)
8651 (forward-line -1)) 8689 (insert ":\n")
8652 ((and off (looking-at re)) 8690 (forward-line -1))
8653 (replace-match "" t t nil 1)) 8691 ((and off (looking-at re))
8654 ((not off) (move-to-column cc t) (insert ":"))) 8692 (replace-match "" t t nil 1))
8655 (forward-line 1))))) 8693 ((not off) (move-to-column cc t) (insert ":")))
8694 (forward-line 1)))
8695 (save-excursion
8696 (org-back-to-heading)
8697 (if (looking-at (concat outline-regexp
8698 "\\( +\\<" org-quote-string "\\>\\)"))
8699 (replace-match "" t t nil 1)
8700 (if (looking-at outline-regexp)
8701 (progn
8702 (goto-char (match-end 0))
8703 (insert " " org-quote-string))))))))
8656 8704
8657 (defun org-export-as-html-and-open (arg) 8705 (defun org-export-as-html-and-open (arg)
8658 "Export the outline as HTML and immediately open it with a browser. 8706 "Export the outline as HTML and immediately open it with a browser.
8659 If there is an active region, export only the region. 8707 If there is an active region, export only the region.
8660 The prefix ARG specifies how many levels of the outline should become 8708 The prefix ARG specifies how many levels of the outline should become
8679 (interactive "P") 8727 (interactive "P")
8680 (setq-default org-todo-line-regexp org-todo-line-regexp) 8728 (setq-default org-todo-line-regexp org-todo-line-regexp)
8681 (setq-default org-deadline-line-regexp org-deadline-line-regexp) 8729 (setq-default org-deadline-line-regexp org-deadline-line-regexp)
8682 (setq-default org-done-string org-done-string) 8730 (setq-default org-done-string org-done-string)
8683 (let* ((region-p (org-region-active-p)) 8731 (let* ((region-p (org-region-active-p))
8684 (region 8732 (region
8685 (buffer-substring 8733 (buffer-substring
8686 (if region-p (region-beginning) (point-min)) 8734 (if region-p (region-beginning) (point-min))
8687 (if region-p (region-end) (point-max)))) 8735 (if region-p (region-end) (point-max))))
8688 (all_lines 8736 (all_lines
8689 (org-skip-comments (org-split-string region "[\r\n]"))) 8737 (org-skip-comments (org-split-string region "[\r\n]")))
8690 (lines (org-export-find-first-heading-line all_lines)) 8738 (lines (org-export-find-first-heading-line all_lines))
8691 (level 0) (line "") (origline "") txt todo 8739 (level 0) (line "") (origline "") txt todo
8692 (umax nil) 8740 (umax nil)
8693 (filename (concat (file-name-sans-extension (buffer-file-name)) 8741 (filename (concat (file-name-sans-extension (buffer-file-name))
8694 ".html")) 8742 ".html"))
8695 (buffer (find-file-noselect filename)) 8743 (buffer (find-file-noselect filename))
8696 (levels-open (make-vector org-level-max nil)) 8744 (levels-open (make-vector org-level-max nil))
8697 (date (format-time-string "%Y/%m/%d" (current-time))) 8745 (date (format-time-string "%Y/%m/%d" (current-time)))
8698 (time (format-time-string "%X" (current-time))) 8746 (time (format-time-string "%X" (current-time)))
8699 (author user-full-name) 8747 (author user-full-name)
8700 (title (buffer-name)) 8748 (title (buffer-name))
8701 (options nil) 8749 (options nil)
8750 (quote-re (concat "^\\*+[ \t]*" org-quote-string "\\>"))
8751 (inquote nil)
8702 (email user-mail-address) 8752 (email user-mail-address)
8703 (language org-export-default-language) 8753 (language org-export-default-language)
8704 (text nil) 8754 (text nil)
8705 (lang-words nil) 8755 (lang-words nil)
8706 (head-count 0) cnt 8756 (head-count 0) cnt
8707 (start 0) 8757 (start 0)
8708 table-open type 8758 table-open type
8709 table-buffer table-orig-buffer 8759 table-buffer table-orig-buffer
8710 ) 8760 )
8714 (org-init-section-numbers) 8764 (org-init-section-numbers)
8715 8765
8716 ;; Search for the export key lines 8766 ;; Search for the export key lines
8717 (org-parse-key-lines) 8767 (org-parse-key-lines)
8718 (setq lang-words (or (assoc language org-export-language-setup) 8768 (setq lang-words (or (assoc language org-export-language-setup)
8719 (assoc "en" org-export-language-setup))) 8769 (assoc "en" org-export-language-setup)))
8720 8770
8721 ;; Switch to the output buffer 8771 ;; Switch to the output buffer
8722 (if (or hidden (not org-export-html-show-new-buffer)) 8772 (if (or hidden (not org-export-html-show-new-buffer))
8723 (set-buffer buffer) 8773 (set-buffer buffer)
8724 (switch-to-buffer-other-window buffer)) 8774 (switch-to-buffer-other-window buffer))
8725 (erase-buffer) 8775 (erase-buffer)
8726 (fundamental-mode) 8776 (fundamental-mode)
8727 (let ((case-fold-search nil)) 8777 (let ((case-fold-search nil))
8728 (if options (org-parse-export-options options)) 8778 (if options (org-parse-export-options options))
8729 (setq umax (if arg (prefix-numeric-value arg) 8779 (setq umax (if arg (prefix-numeric-value arg)
8730 org-export-headline-levels)) 8780 org-export-headline-levels))
8731 8781
8732 ;; File header 8782 ;; File header
8733 (insert (format 8783 (insert (format
8734 "<html lang=\"%s\"><head> 8784 "<html lang=\"%s\"><head>
8735 <title>%s</title> 8785 <title>%s</title>
8736 <meta http-equiv=\"Content-Type\" content=\"text/html\"> 8786 <meta http-equiv=\"Content-Type\" content=\"text/html\">
8737 <meta name=generator content=\"Org-mode\"> 8787 <meta name=generator content=\"Org-mode\">
8738 <meta name=generated content=\"%s %s\"> 8788 <meta name=generated content=\"%s %s\">
8739 <meta name=author content=\"%s\"> 8789 <meta name=author content=\"%s\">
8740 </head><body> 8790 </head><body>
8741 " 8791 "
8742 language (org-html-expand title) date time author)) 8792 language (org-html-expand title) date time author))
8743 (if title (insert (concat "<H1 align=\"center\">" 8793 (if title (insert (concat "<H1 align=\"center\">"
8744 (org-html-expand title) "</H1>\n"))) 8794 (org-html-expand title) "</H1>\n")))
8745 (if author (insert (concat (nth 1 lang-words) ": " author "\n"))) 8795 (if author (insert (concat (nth 1 lang-words) ": " author "\n")))
8746 (if email (insert (concat "<a href=\"mailto:" email "\">&lt;" 8796 (if email (insert (concat "<a href=\"mailto:" email "\">&lt;"
8747 email "&gt;</a>\n"))) 8797 email "&gt;</a>\n")))
8748 (if (or author email) (insert "<br>\n")) 8798 (if (or author email) (insert "<br>\n"))
8749 (if (and date time) (insert (concat (nth 2 lang-words) ": " 8799 (if (and date time) (insert (concat (nth 2 lang-words) ": "
8750 date " " time "<br>\n"))) 8800 date " " time "<br>\n")))
8751 (if text (insert (concat "<p>\n" (org-html-expand text)))) 8801 (if text (insert (concat "<p>\n" (org-html-expand text))))
8752 (if org-export-with-toc 8802 (if org-export-with-toc
8753 (progn 8803 (progn
8754 (insert (format "<H2>%s</H2>\n" (nth 3 lang-words))) 8804 (insert (format "<H2>%s</H2>\n" (nth 3 lang-words)))
8755 (insert "<ul>\n") 8805 (insert "<ul>\n")
8800 (setq org-last-level (1- org-last-level)) 8850 (setq org-last-level (1- org-last-level))
8801 (insert "</ul>\n")) 8851 (insert "</ul>\n"))
8802 )) 8852 ))
8803 (setq head-count 0) 8853 (setq head-count 0)
8804 (org-init-section-numbers) 8854 (org-init-section-numbers)
8855
8805 (while (setq line (pop lines) origline line) 8856 (while (setq line (pop lines) origline line)
8806 ;; Protect the links 8857 ;; end of quote?
8807 (setq start 0) 8858 (when (and inquote (string-match "^\\*+" line))
8808 (while (string-match org-link-maybe-angles-regexp line start) 8859 (insert "</pre>\n")
8809 (setq start (match-end 0)) 8860 (setq inquote nil))
8810 (setq line (replace-match 8861 ;; inquote
8811 (concat "\000" (match-string 1 line) "\000") 8862 (if inquote
8812 t t line)))
8813
8814 ;; replace "<" and ">" by "&lt;" and "&gt;"
8815 ;; handle @<..> HTML tags (replace "@&gt;..&lt;" by "<..>")
8816 (setq line (org-html-expand line))
8817
8818 ;; Verbatim lines
8819 (if (and org-export-with-fixed-width
8820 (string-match "^[ \t]*:\\(.*\\)" line))
8821 (progn 8863 (progn
8822 (let ((l (match-string 1 line))) 8864 (insert line "\n")
8823 (while (string-match " " l) 8865 (setq line (org-html-expand line))) ;;????? FIXME: not needed?
8824 (setq l (replace-match "&nbsp;" t t l))) 8866
8825 (insert "\n<span style='font-family:Courier'>" 8867 ;; Protect the links
8826 l "</span>"
8827 (if (and lines
8828 (not (string-match "^[ \t]+\\(:.*\\)"
8829 (car lines))))
8830 "<br>\n" "\n"))))
8831 (setq start 0) 8868 (setq start 0)
8832 (while (string-match org-protected-link-regexp line start) 8869 (while (string-match org-link-maybe-angles-regexp line start)
8833 (setq start (- (match-end 0) 2)) 8870 (setq start (match-end 0))
8834 (setq type (match-string 1 line)) 8871 (setq line (replace-match
8872 (concat "\000" (match-string 1 line) "\000")
8873 t t line)))
8874
8875 ;; replace "<" and ">" by "&lt;" and "&gt;"
8876 ;; handle @<..> HTML tags (replace "@&gt;..&lt;" by "<..>")
8877 (setq line (org-html-expand line))
8878
8879 ;; Verbatim lines
8880 (if (and org-export-with-fixed-width
8881 (string-match "^[ \t]*:\\(.*\\)" line))
8882 (progn
8883 (let ((l (match-string 1 line)))
8884 (while (string-match " " l)
8885 (setq l (replace-match "&nbsp;" t t l)))
8886 (insert "\n<span style='font-family:Courier'>"
8887 l "</span>"
8888 (if (and lines
8889 (not (string-match "^[ \t]+\\(:.*\\)"
8890 (car lines))))
8891 "<br>\n" "\n"))))
8892
8893 (setq start 0)
8894 (while (string-match org-protected-link-regexp line start)
8895 (setq start (- (match-end 0) 2))
8896 (setq type (match-string 1 line))
8897 (cond
8898 ((member type '("http" "https" "ftp" "mailto" "news"))
8899 ;; standard URL
8900 (setq line (replace-match
8901 ; "<a href=\"\\1:\\2\">&lt;\\1:\\2&gt;</a>"
8902 "<a href=\"\\1:\\2\">\\1:\\2</a>"
8903 nil nil line)))
8904 ((string= type "file")
8905 ;; FILE link
8906 (let* ((filename (match-string 2 line))
8907 (abs-p (file-name-absolute-p filename))
8908 (thefile (if abs-p (expand-file-name filename) filename))
8909 (thefile (save-match-data
8910 (if (string-match ":[0-9]+$" thefile)
8911 (replace-match "" t t thefile)
8912 thefile)))
8913 (file-is-image-p
8914 (save-match-data
8915 (string-match (org-image-file-name-regexp) thefile))))
8916 (setq line (replace-match
8917 (if (and org-export-html-inline-images
8918 file-is-image-p)
8919 (concat "<img src=\"" thefile "\"/>")
8920 (concat "<a href=\"" thefile "\">\\1:\\2</a>"))
8921 nil nil line))))
8922
8923 ((member type '("bbdb" "vm" "wl" "rmail" "gnus" "shell"))
8924 (setq line (replace-match
8925 "<i>&lt;\\1:\\2&gt;</i>" nil nil line)))))
8926
8927 ;; TODO items
8928 (if (and (string-match org-todo-line-regexp line)
8929 (match-beginning 2))
8930 (if (equal (match-string 2 line) org-done-string)
8931 (setq line (replace-match
8932 "<span style='color:green'>\\2</span>"
8933 nil nil line 2))
8934 (setq line (replace-match "<span style='color:red'>\\2</span>"
8935 nil nil line 2))))
8936
8937 ;; DEADLINES
8938 (if (string-match org-deadline-line-regexp line)
8939 (progn
8940 (if (save-match-data
8941 (string-match "<a href"
8942 (substring line 0 (match-beginning 0))))
8943 nil ; Don't do the replacement - it is inside a link
8944 (setq line (replace-match "<span style='color:red'>\\&</span>"
8945 nil nil line 1)))))
8946
8947
8835 (cond 8948 (cond
8836 ((member type '("http" "https" "ftp" "mailto" "news")) 8949 ((string-match "^\\(\\*+\\)[ \t]*\\(.*\\)" line)
8837 ;; standard URL 8950 ;; This is a headline
8838 (setq line (replace-match 8951 (setq level (- (match-end 1) (match-beginning 1))
8839 ; "<a href=\"\\1:\\2\">&lt;\\1:\\2&gt;</a>" 8952 txt (match-string 2 line))
8840 "<a href=\"\\1:\\2\">\\1:\\2</a>" 8953 (if (<= level umax) (setq head-count (+ head-count 1)))
8841 nil nil line))) 8954 (org-html-level-start level txt umax
8842 ((string= type "file") 8955 (and org-export-with-toc (<= level umax))
8843 ;; FILE link 8956 head-count)
8844 (let* ((filename (match-string 2 line)) 8957 ;; QUOTES
8845 (abs-p (file-name-absolute-p filename)) 8958 (when (string-match quote-re line)
8846 (thefile (if abs-p (expand-file-name filename) filename)) 8959 (insert "<pre>")
8847 (thefile (save-match-data 8960 (setq inquote t)))
8848 (if (string-match ":[0-9]+$" thefile) 8961
8849 (replace-match "" t t thefile) 8962 ((and org-export-with-tables
8850 thefile))) 8963 (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" line))
8851 (file-is-image-p 8964 (if (not table-open)
8852 (save-match-data 8965 ;; New table starts
8853 (string-match (org-image-file-name-regexp) thefile)))) 8966 (setq table-open t table-buffer nil table-orig-buffer nil))
8854 (setq line (replace-match 8967 ;; Accumulate lines
8855 (if (and org-export-html-inline-images 8968 (setq table-buffer (cons line table-buffer)
8856 file-is-image-p) 8969 table-orig-buffer (cons origline table-orig-buffer))
8857 (concat "<img src=\"" thefile "\"/>") 8970 (when (or (not lines)
8858 (concat "<a href=\"" thefile "\">\\1:\\2</a>")) 8971 (not (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)"
8859 nil nil line)))) 8972 (car lines))))
8860 8973 (setq table-open nil
8861 ((member type '("bbdb" "vm" "wl" "rmail" "gnus" "shell")) 8974 table-buffer (nreverse table-buffer)
8862 (setq line (replace-match 8975 table-orig-buffer (nreverse table-orig-buffer))
8863 "<i>&lt;\\1:\\2&gt;</i>" nil nil line))))) 8976 (insert (org-format-table-html table-buffer table-orig-buffer))))
8864 8977 (t
8865 ;; TODO items 8978 ;; Normal lines
8866 (if (and (string-match org-todo-line-regexp line) 8979 ;; Lines starting with "-", and empty lines make new paragraph.
8867 (match-beginning 2)) 8980 ;; FIXME: Should we add + and *?
8868 (if (equal (match-string 2 line) org-done-string) 8981 (if (string-match "^ *-\\|^[ \t]*$" line) (insert "<p>"))
8869 (setq line (replace-match 8982 (insert line (if org-export-preserve-breaks "<br>\n" "\n"))))
8870 "<span style='color:green'>\\2</span>" 8983 )))
8871 nil nil line 2)) 8984 (if org-export-html-with-timestamp
8872 (setq line (replace-match "<span style='color:red'>\\2</span>" 8985 (insert org-export-html-html-helper-timestamp))
8873 nil nil line 2)))) 8986 (insert "</body>\n</html>\n")
8874 8987 (normal-mode)
8875 ;; DEADLINES 8988 (save-buffer)
8876 (if (string-match org-deadline-line-regexp line) 8989 (goto-char (point-min)))))
8877 (progn
8878 (if (save-match-data
8879 (string-match "<a href"
8880 (substring line 0 (match-beginning 0))))
8881 nil ; Don't do the replacement - it is inside a link
8882 (setq line (replace-match "<span style='color:red'>\\&</span>"
8883 nil nil line 1)))))
8884
8885 (cond
8886 ((string-match "^\\(\\*+\\)[ \t]*\\(.*\\)" line)
8887 ;; This is a headline
8888 (setq level (- (match-end 1) (match-beginning 1))
8889 txt (match-string 2 line))
8890 (if (<= level umax) (setq head-count (+ head-count 1)))
8891 (org-html-level-start level txt umax
8892 (and org-export-with-toc (<= level umax))
8893 head-count))
8894
8895 ((and org-export-with-tables
8896 (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" line))
8897 (if (not table-open)
8898 ;; New table starts
8899 (setq table-open t table-buffer nil table-orig-buffer nil))
8900 ;; Accumulate lines
8901 (setq table-buffer (cons line table-buffer)
8902 table-orig-buffer (cons origline table-orig-buffer))
8903 (when (or (not lines)
8904 (not (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)"
8905 (car lines))))
8906 (setq table-open nil
8907 table-buffer (nreverse table-buffer)
8908 table-orig-buffer (nreverse table-orig-buffer))
8909 (insert (org-format-table-html table-buffer table-orig-buffer))))
8910 (t
8911 ;; Normal lines
8912 ;; Lines starting with "-", and empty lines make new paragraph.
8913 ;; FIXME: Should we add + and *?
8914 (if (string-match "^ *-\\|^[ \t]*$" line) (insert "<p>"))
8915 (insert line (if org-export-preserve-breaks "<br>\n" "\n"))))
8916 ))
8917 (if org-export-html-with-timestamp
8918 (insert org-export-html-html-helper-timestamp))
8919 (insert "</body>\n</html>\n")
8920 (normal-mode)
8921 (save-buffer)
8922 (goto-char (point-min)))))
8923 8990
8924 (defun org-format-table-html (lines olines) 8991 (defun org-format-table-html (lines olines)
8925 "Find out which HTML converter to use and return the HTML code." 8992 "Find out which HTML converter to use and return the HTML code."
8926 (if (string-match "^[ \t]*|" (car lines)) 8993 (if (string-match "^[ \t]*|" (car lines))
8927 ;; A normal org table 8994 ;; A normal org table
9227 (aset org-section-numbers i 0) 9294 (aset org-section-numbers i 0)
9228 (setq number-string (or (car numbers) "0")) 9295 (setq number-string (or (car numbers) "0"))
9229 (if (string-match "\\`[A-Z]\\'" number-string) 9296 (if (string-match "\\`[A-Z]\\'" number-string)
9230 (aset org-section-numbers i 9297 (aset org-section-numbers i
9231 (- (string-to-char number-string) ?A -1)) 9298 (- (string-to-char number-string) ?A -1))
9232 (aset org-section-numbers i (string-to-int number-string))) 9299 (aset org-section-numbers i (string-to-number number-string)))
9233 (pop numbers)) 9300 (pop numbers))
9234 (setq i (1- i))))) 9301 (setq i (1- i)))))
9235 9302
9236 (defun org-section-number (&optional level) 9303 (defun org-section-number (&optional level)
9237 "Return a string with the current section number. 9304 "Return a string with the current section number.
9996 "#?[ \t]*\\+\\(" 10063 "#?[ \t]*\\+\\("
9997 (mapconcat 'regexp-quote kwds "\\|") 10064 (mapconcat 'regexp-quote kwds "\\|")
9998 "\\):[ \t]*" 10065 "\\):[ \t]*"
9999 (if org-noutline-p "\\(.+\\)" "\\([^\n\r]+\\)"))) 10066 (if org-noutline-p "\\(.+\\)" "\\([^\n\r]+\\)")))
10000 10067
10001 ;; Advise the bookmark-jump function to make jump position visible 10068 ;; Make `bookmark-jump' show the jump location if it was hidden.
10002 ;; Wrapped into eval-after-load to avoid loading advice unnecessarily
10003 (eval-after-load "bookmark" 10069 (eval-after-load "bookmark"
10004 '(defadvice bookmark-jump (after org-make-visible activate) 10070 '(if (boundp 'bookmark-after-jump-hook)
10005 "Make the position visible." 10071 ;; We can use the hook
10006 (and (eq major-mode 'org-mode) 10072 (add-hook 'bookmark-after-jump-hook 'org-bookmark-jump-unhide)
10007 (org-invisible-p) 10073 ;; Hook not available, use advice
10008 (org-show-hierarchy-above)))) 10074 (defadvice bookmark-jump (after org-make-visible activate)
10075 "Make the position visible."
10076 (org-bookmark-jump-unhide))))
10077
10078 (defun org-bookmark-jump-unhide ()
10079 "Unhide the current position, to show the bookmark location."
10080 (and (eq major-mode 'org-mode)
10081 (or (org-invisible-p)
10082 (save-excursion (goto-char (max (point-min) (1- (point))))
10083 (org-invisible-p)))
10084 (org-show-hierarchy-above)))
10009 10085
10010 ;;; Finish up 10086 ;;; Finish up
10011 10087
10012 (provide 'org) 10088 (provide 'org)
10013 10089