aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Dominik2006-03-01 07:07:01 +0000
committerCarsten Dominik2006-03-01 07:07:01 +0000
commit79c4be8e2e29c5453e6fc93fcc9ff16f45207b51 (patch)
treef49ae9670e770b1307a1080f52571c172651aa08
parentd464ce2789b4eb135d386950646c214b7699fd3f (diff)
downloademacs-79c4be8e2e29c5453e6fc93fcc9ff16f45207b51.tar.gz
emacs-79c4be8e2e29c5453e6fc93fcc9ff16f45207b51.zip
(org-export-as-html): Fixed bugs in HTML
formatting: No nested anchors. (org-all-targets): Fixed bug with XEmacs compatibility. (org-read-date): Add (require 'parse-time). (org-set-tags): Fixed bug with extra inserted space. (org-export-html-style): Define a style class for targets. (org-agenda-keymap, org-mouse-map): Added a binding for `follow-link'. (org-hide-leading-stars): New option. (org-hide): New face. (org-set-font-lock-defaults): Allow to hide leading stars. (org-get-legal-level, org-tr-level): New functions. (org-odd-levels-only): New option. (org-level-faces, org-paste-subtree, org-convert-to-odd-levels, org-demote, org-promote): Deal with double-star levels. (org-convert-to-odd-levels): New command.
-rw-r--r--lisp/textmodes/org.el250
1 files changed, 185 insertions, 65 deletions
diff --git a/lisp/textmodes/org.el b/lisp/textmodes/org.el
index cecfe7f5164..fd21159b7eb 100644
--- a/lisp/textmodes/org.el
+++ b/lisp/textmodes/org.el
@@ -5,7 +5,7 @@
5;; Author: Carsten Dominik <dominik at science dot uva dot nl> 5;; Author: Carsten Dominik <dominik at science dot uva dot nl>
6;; Keywords: outlines, hypermedia, calendar, wp 6;; Keywords: outlines, hypermedia, calendar, wp
7;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/ 7;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/
8;; Version: 4.06 8;; Version: 4.07
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
@@ -81,6 +81,12 @@
81;; 81;;
82;; Changes since version 4.00: 82;; Changes since version 4.00:
83;; --------------------------- 83;; ---------------------------
84;; Version 4.07
85;; - Bug fixes.
86;; - Leading stars in headlines can be hidden, so make the outline look
87;; cleaner.
88;; - Mouse-1 can be used to follow links.
89;;
84;; Version 4.06 90;; Version 4.06
85;; - HTML exporter treats targeted internal links. 91;; - HTML exporter treats targeted internal links.
86;; - Bug fixes. 92;; - Bug fixes.
@@ -130,7 +136,7 @@
130 136
131;;; Customization variables 137;;; Customization variables
132 138
133(defvar org-version "4.06" 139(defvar org-version "4.07"
134 "The version number of the file org.el.") 140 "The version number of the file org.el.")
135(defun org-version () 141(defun org-version ()
136 (interactive) 142 (interactive)
@@ -794,6 +800,24 @@ Changing it requires restart of Emacs to become effective."
794 :group 'org-structure 800 :group 'org-structure
795 :type 'boolean) 801 :type 'boolean)
796 802
803(defcustom org-hide-leading-stars nil
804 "Non-nil means, hide the first N-1 stars in a headline.
805This works by using the face `org-hide' for these stars. This
806face is white for a light background, and black for a dark
807background. You may have to customize the face `org-hide' to
808make this work.
809Changing the variable requires restart of Emacs to become effective."
810 :group 'org-structure
811 :type 'boolean)
812
813(defcustom org-odd-levels-only nil
814 "Non-nil means, skip even levels and only use odd levels for the outline.
815This has the effect that two stars are being added/taken away in
816promotion/demotion commands. It also influences how levels are
817handled by the exporters."
818 :group 'org-structure
819 :type 'boolean)
820
797(defcustom org-adapt-indentation t 821(defcustom org-adapt-indentation t
798 "Non-nil means, adapt indentation when promoting and demoting. 822 "Non-nil means, adapt indentation when promoting and demoting.
799When this is set and the *entire* text in an entry is indented, the 823When this is set and the *entire* text in an entry is indented, the
@@ -1409,6 +1433,7 @@ This should have an association in `org-export-language-setup'."
1409 .title { text-align: center; } 1433 .title { text-align: center; }
1410 .todo, .deadline { color: red; } 1434 .todo, .deadline { color: red; }
1411 .done { color: green; } 1435 .done { color: green; }
1436 .target { background-color: lavender; }
1412 pre { 1437 pre {
1413 border: 1pt solid #AEBDCC; 1438 border: 1pt solid #AEBDCC;
1414 background-color: #F3F5F7; 1439 background-color: #F3F5F7;
@@ -1633,7 +1658,7 @@ This option can also be set with the +OPTIONS line, e.g. \"TeX:nil\"."
1633 1658
1634(defcustom org-export-html-with-timestamp nil 1659(defcustom org-export-html-with-timestamp nil
1635 "If non-nil, write `org-export-html-html-helper-timestamp' 1660 "If non-nil, write `org-export-html-html-helper-timestamp'
1636into the exported html text. Otherwise, the buffer will just be saved 1661into the exported HTML text. Otherwise, the buffer will just be saved
1637to a file." 1662to a file."
1638 :group 'org-export 1663 :group 'org-export
1639 :type 'boolean) 1664 :type 'boolean)
@@ -1651,7 +1676,7 @@ Otherwise the buffer will just be saved to a file and stay hidden."
1651 :type 'boolean) 1676 :type 'boolean)
1652 1677
1653(defcustom org-export-html-show-new-buffer nil 1678(defcustom org-export-html-show-new-buffer nil
1654 "Non-nil means, popup buffer containing the exported HTML text. 1679 "Non-nil means, popup buffer containing the exported html text.
1655Otherwise, the buffer will just be saved to a file and stay hidden." 1680Otherwise, the buffer will just be saved to a file and stay hidden."
1656 :group 'org-export 1681 :group 'org-export
1657 :type 'boolean) 1682 :type 'boolean)
@@ -1677,6 +1702,16 @@ This file is created with the command \\[org-export-icalendar-all-agenda-files].
1677 :tag "Org Faces" 1702 :tag "Org Faces"
1678 :group 'org) 1703 :group 'org)
1679 1704
1705(defface org-hide
1706 '((((type tty) (class color)) (:foreground "blue" :weight bold))
1707 (((class color) (background light)) (:foreground "white"))
1708 (((class color) (background dark)) (:foreground "black"))
1709; (((class color) (background light)) (:foreground "grey90"))
1710; (((class color) (background dark)) (:foreground "grey10"))
1711 (t (:inverse-video nil)))
1712 "Face used for level 1 headlines."
1713 :group 'org-faces)
1714
1680(defface org-level-1 ;; font-lock-function-name-face 1715(defface org-level-1 ;; font-lock-function-name-face
1681 '((((type tty) (class color)) (:foreground "blue" :weight bold)) 1716 '((((type tty) (class color)) (:foreground "blue" :weight bold))
1682 (((class color) (background light)) (:foreground "Blue")) 1717 (((class color) (background light)) (:foreground "Blue"))
@@ -1844,17 +1879,25 @@ When this is non-nil, the headline after the keyword is set to the
1844 "Face used for time grids." 1879 "Face used for time grids."
1845 :group 'org-faces) 1880 :group 'org-faces)
1846 1881
1847(defvar org-level-faces 1882(defvar org-level-faces nil)
1848 '( 1883
1849 org-level-1 1884(when (not org-level-faces)
1850 org-level-2 1885 (setq org-level-faces
1851 org-level-3 1886 '(
1852 org-level-4 1887 org-level-1
1853 org-level-5 1888 org-level-2
1854 org-level-6 1889 org-level-3
1855 org-level-7 1890 org-level-4
1856 org-level-8 1891 org-level-5
1857 )) 1892 org-level-6
1893 org-level-7
1894 org-level-8
1895 ))
1896 (when org-odd-levels-only
1897 (setq org-level-faces (apply 'append (mapcar (lambda (x) (list x x))
1898 org-level-faces)))
1899 (setq org-level-faces (append (cdr org-level-faces) (list 'org-level-1)))))
1900
1858(defvar org-n-levels (length org-level-faces)) 1901(defvar org-n-levels (length org-level-faces))
1859 1902
1860(defun org-set-regexps-and-options () 1903(defun org-set-regexps-and-options ()
@@ -1985,7 +2028,6 @@ When this is non-nil, the headline after the keyword is set to the
1985 (defvar remember-data-file) 2028 (defvar remember-data-file)
1986 (defvar last-arg)) 2029 (defvar last-arg))
1987 2030
1988
1989;;; Define the mode 2031;;; Define the mode
1990 2032
1991(defvar org-mode-map (copy-keymap outline-mode-map) 2033(defvar org-mode-map (copy-keymap outline-mode-map)
@@ -2000,7 +2042,7 @@ When this is non-nil, the headline after the keyword is set to the
2000(defvar org-table-may-need-update t 2042(defvar org-table-may-need-update t
2001 "Indicates that a table might need an update. 2043 "Indicates that a table might need an update.
2002This variable is set by `org-before-change-function'. 2044This variable is set by `org-before-change-function'.
2003`org-table-align'sets it back to nil.") 2045`org-table-align' sets it back to nil.")
2004(defvar org-mode-hook nil) 2046(defvar org-mode-hook nil)
2005(defvar org-inhibit-startup nil) ; Dynamically-scoped param. 2047(defvar org-inhibit-startup nil) ; Dynamically-scoped param.
2006(defvar org-agenda-keep-modes nil) ; Dynamically-scoped param. 2048(defvar org-agenda-keep-modes nil) ; Dynamically-scoped param.
@@ -2090,6 +2132,7 @@ The following commands are available:
2090 (if org-xemacs-p [button2] [mouse-2]) 'org-open-at-mouse) 2132 (if org-xemacs-p [button2] [mouse-2]) 'org-open-at-mouse)
2091(define-key org-mouse-map 2133(define-key org-mouse-map
2092 (if org-xemacs-p [button3] [mouse-3]) 'org-find-file-at-mouse) 2134 (if org-xemacs-p [button3] [mouse-3]) 'org-find-file-at-mouse)
2135(define-key org-mouse-map [follow-link] 'mouse-face)
2093(when org-tab-follows-link 2136(when org-tab-follows-link
2094 (define-key org-mouse-map [(tab)] 'org-open-at-point) 2137 (define-key org-mouse-map [(tab)] 'org-open-at-point)
2095 (define-key org-mouse-map "\C-i" 'org-open-at-point)) 2138 (define-key org-mouse-map "\C-i" 'org-open-at-point))
@@ -2200,7 +2243,10 @@ With optional argument RADIO, only find radio targets."
2200 (save-excursion 2243 (save-excursion
2201 (goto-char (point-min)) 2244 (goto-char (point-min))
2202 (while (re-search-forward re nil t) 2245 (while (re-search-forward re nil t)
2203 (add-to-list 'rtn (downcase (match-string-no-properties 1)))) 2246 (add-to-list 'rtn (downcase
2247 (if (fboundp 'match-string-no-properties)
2248 (match-string-no-properties 1)
2249 (match-string 1)))))
2204 rtn))) 2250 rtn)))
2205 2251
2206(defun org-make-target-link-regexp (targets) 2252(defun org-make-target-link-regexp (targets)
@@ -2274,8 +2320,6 @@ between words."
2274 ;; (3 'italic)) 2320 ;; (3 'italic))
2275 ;; '("\\(\\s-\\|^\\)\\(_\\([a-zA-Z]+\\)_\\)\\([^a-zA-Z*]\\|$\\)" 2321 ;; '("\\(\\s-\\|^\\)\\(_\\([a-zA-Z]+\\)_\\)\\([^a-zA-Z*]\\|$\\)"
2276 ;; (3 'underline)) 2322 ;; (3 'underline))
2277; (list (concat "^\\*+[ \t]*\\<\\(" org-comment-string "\\)\\>")
2278; '(1 'org-warning t))
2279 (list (concat "^\\*+[ \t]*\\<\\(" org-comment-string 2323 (list (concat "^\\*+[ \t]*\\<\\(" org-comment-string
2280 "\\|" org-quote-string "\\)\\>") 2324 "\\|" org-quote-string "\\)\\>")
2281 '(1 'org-special-keyword t)) 2325 '(1 'org-special-keyword t))
@@ -2290,24 +2334,25 @@ between words."
2290 '("^[ \t]*\\(:.*\\)" (1 'org-table t)) 2334 '("^[ \t]*\\(:.*\\)" (1 'org-table t))
2291 '("| *\\(:?=[^|\n]*\\)" (1 'org-formula t)) 2335 '("| *\\(:?=[^|\n]*\\)" (1 'org-formula t))
2292 '("^[ \t]*| *\\([#!$*_^]\\) *|" (1 'org-formula t)) 2336 '("^[ \t]*| *\\([#!$*_^]\\) *|" (1 'org-formula t))
2293 ))) 2337 ))
2338 (exp
2339 ;; The font-lock expression for headlines is complicated. It depends
2340 ;; on two user options, and it needs to determine the level in
2341 ;; order to compute the level.
2342 (cond
2343 ((and org-level-color-stars-only (not org-hide-leading-stars))
2344 '("^\\(\\*+\\).*" 1 (nth (% (- (match-end 1) (match-beginning 1) 1) org-n-levels) org-level-faces) nil t))
2345 ((and (not org-level-color-stars-only) org-hide-leading-stars)
2346 '("^\\(\\**\\)\\(\\*.*\\)" (1 'org-hide) (2 (nth (% (- (match-end 1) (match-beginning 1)) org-n-levels) org-level-faces) nil t)))
2347 ((and org-level-color-stars-only org-hide-leading-stars)
2348 '("^\\(\\**\\)\\(\\*\\).*" (1 'org-hide) (2 (nth (% (- (match-end 1) (match-beginning 1)) org-n-levels) org-level-faces) nil t)))
2349 (t
2350 '("^\\(\\*+\\).*" 0 (nth (% (- (match-end 1) (match-beginning 1) 1) org-n-levels) org-level-faces) nil t)))))
2351
2352 ;; Now set the full font-lock-keywords
2294 (set (make-local-variable 'org-font-lock-keywords) 2353 (set (make-local-variable 'org-font-lock-keywords)
2295 (append 2354 (append
2296 (if org-noutline-p ; FIXME: I am not sure if eval will work 2355 (if org-xemacs-p (list exp) (list (cons 'eval (list 'quote exp))))
2297 ; on XEmacs if noutline is ever ported
2298 `((eval . (list "^\\(\\*+\\).*"
2299 ,(if org-level-color-stars-only 1 0)
2300 '(nth
2301 (% (- (match-end 1) (match-beginning 1) 1)
2302 org-n-levels)
2303 org-level-faces)
2304 nil t)))
2305 `(("^\\(\\(\\*+\\)[^\r\n]*\\)[\n\r]"
2306 (,(if org-level-color-stars-only 2 0)
2307 (nth (% (- (match-end 2) (match-beginning 2) 1)
2308 org-n-levels)
2309 org-level-faces)
2310 nil t))))
2311 org-font-lock-extra-keywords)) 2356 org-font-lock-extra-keywords))
2312 (set (make-local-variable 'font-lock-defaults) 2357 (set (make-local-variable 'font-lock-defaults)
2313 '(org-font-lock-keywords t nil nil backward-paragraph)) 2358 '(org-font-lock-keywords t nil nil backward-paragraph))
@@ -2731,19 +2776,32 @@ in the region."
2731 (equal (char-before) ?*) 2776 (equal (char-before) ?*)
2732 (forward-char 1))) 2777 (forward-char 1)))
2733 2778
2779(defun org-get-legal-level (level change)
2780 "Rectify a level change under the influence of `org-odd-levels-only'
2781LEVEL is a current level, CHANGE is by how much the level should be
2782modified. Even if CHANGE is nil, LEVEL may be returned modified because
2783even level numbers will become the next higher odd number."
2784 (if org-odd-levels-only
2785 (cond ((not change) (1+ (* 2 (/ level 2))))
2786 ((> change 0) (1+ (* 2 (/ (+ level (* 2 change)) 2))))
2787 ((< change 0) (max 1 (1+ (* 2 (/ (+ level (* 2 change)) 2))))))
2788 (max 1 (+ level change))))
2789
2734(defun org-promote () 2790(defun org-promote ()
2735 "Promote the current heading higher up the tree. 2791 "Promote the current heading higher up the tree.
2736If the region is active in `transient-mark-mode', promote all headings 2792If the region is active in `transient-mark-mode', promote all headings
2737in the region." 2793in the region."
2738 (org-back-to-heading t) 2794 (org-back-to-heading t)
2739 (let* ((level (save-match-data (funcall outline-level))) 2795 (let* ((level (save-match-data (funcall outline-level)))
2740 (up-head (make-string (1- level) ?*))) 2796 (up-head (make-string (org-get-legal-level level -1) ?*))
2797 (diff (abs (- level (length up-head)))))
2741 (if (= level 1) (error "Cannot promote to level 0. UNDO to recover")) 2798 (if (= level 1) (error "Cannot promote to level 0. UNDO to recover"))
2742 (replace-match up-head nil t) 2799 (replace-match up-head nil t)
2743 ;; Fixup tag positioning 2800 ;; Fixup tag positioning
2744 (and org-auto-align-tags (org-set-tags nil t)) 2801 (and org-auto-align-tags (org-set-tags nil t))
2745 (if org-adapt-indentation 2802 (if org-adapt-indentation
2746 (org-fixup-indentation "^ " "" "^ ?\\S-")))) 2803 (org-fixup-indentation (if (> diff 1) "^ " "^ ") ""
2804 (if (> diff 1) "^ ? ?\\S-" "^ ?\\S-")))))
2747 2805
2748(defun org-demote () 2806(defun org-demote ()
2749 "Demote the current heading lower down the tree. 2807 "Demote the current heading lower down the tree.
@@ -2751,12 +2809,13 @@ If the region is active in `transient-mark-mode', demote all headings
2751in the region." 2809in the region."
2752 (org-back-to-heading t) 2810 (org-back-to-heading t)
2753 (let* ((level (save-match-data (funcall outline-level))) 2811 (let* ((level (save-match-data (funcall outline-level)))
2754 (down-head (make-string (1+ level) ?*))) 2812 (down-head (make-string (org-get-legal-level level 1) ?*))
2813 (diff (abs (- level (length down-head)))))
2755 (replace-match down-head nil t) 2814 (replace-match down-head nil t)
2756 ;; Fixup tag positioning 2815 ;; Fixup tag positioning
2757 (and org-auto-align-tags (org-set-tags nil t)) 2816 (and org-auto-align-tags (org-set-tags nil t))
2758 (if org-adapt-indentation 2817 (if org-adapt-indentation
2759 (org-fixup-indentation "^ " " " "^\\S-")))) 2818 (org-fixup-indentation "^ " (if (> diff 1) " " " ") "^\\S-"))))
2760 2819
2761(defun org-map-tree (fun) 2820(defun org-map-tree (fun)
2762 "Call FUN for every heading underneath the current one." 2821 "Call FUN for every heading underneath the current one."
@@ -2885,6 +2944,7 @@ If CUT is non nil, actually cut the subtree."
2885 (if cut "Cut" "Copied") 2944 (if cut "Cut" "Copied")
2886 (length org-subtree-clip))))) 2945 (length org-subtree-clip)))))
2887 2946
2947;; FIXME: this needs to be adapted for the odd-level-only stuff.
2888(defun org-paste-subtree (&optional level tree) 2948(defun org-paste-subtree (&optional level tree)
2889 "Paste the clipboard as a subtree, with modification of headline level. 2949 "Paste the clipboard as a subtree, with modification of headline level.
2890The entire subtree is promoted or demoted in order to match a new headline 2950The entire subtree is promoted or demoted in order to match a new headline
@@ -2903,6 +2963,7 @@ If you want to insert the tree as is, just use \\[yank].
2903 2963
2904If optional TREE is given, use this text instead of the kill ring." 2964If optional TREE is given, use this text instead of the kill ring."
2905 (interactive "P") 2965 (interactive "P")
2966 (debug)
2906 (unless (org-kill-is-subtree-p tree) 2967 (unless (org-kill-is-subtree-p tree)
2907 (error 2968 (error
2908 (substitute-command-keys 2969 (substitute-command-keys
@@ -2945,6 +3006,7 @@ If optional TREE is given, use this text instead of the kill ring."
2945 (shift1 shift) 3006 (shift1 shift)
2946 (delta (if (> shift 0) -1 1)) 3007 (delta (if (> shift 0) -1 1))
2947 (func (if (> shift 0) 'org-demote 'org-promote)) 3008 (func (if (> shift 0) 'org-demote 'org-promote))
3009 (org-odd-levels-only nil)
2948 beg end) 3010 beg end)
2949 ;; Remove the forces level indicator 3011 ;; Remove the forces level indicator
2950 (if force-level 3012 (if force-level
@@ -3827,6 +3889,7 @@ insert a time. Note that when WITH-TIME is not set, you can still
3827enter a time, and this function will inform the calling routine about 3889enter a time, and this function will inform the calling routine about
3828this change. The calling routine may then choose to change the format 3890this change. The calling routine may then choose to change the format
3829used to insert the time stamp into the buffer to include the time." 3891used to insert the time stamp into the buffer to include the time."
3892 (require 'parse-time)
3830 (let* ((default-time 3893 (let* ((default-time
3831 ;; Default time is either today, or, when entering a range, 3894 ;; Default time is either today, or, when entering a range,
3832 ;; the range start. 3895 ;; the range start.
@@ -4348,7 +4411,7 @@ The following commands are available:
4348 (if org-xemacs-p [(button2)] [(mouse-2)]) 'org-agenda-goto-mouse) 4411 (if org-xemacs-p [(button2)] [(mouse-2)]) 'org-agenda-goto-mouse)
4349(define-key org-agenda-keymap 4412(define-key org-agenda-keymap
4350 (if org-xemacs-p [(button3)] [(mouse-3)]) 'org-agenda-show-mouse) 4413 (if org-xemacs-p [(button3)] [(mouse-3)]) 'org-agenda-show-mouse)
4351 4414(define-key org-agenda-keymap [follow-link] 'mouse-face)
4352(easy-menu-define org-agenda-menu org-agenda-mode-map "Agenda menu" 4415(easy-menu-define org-agenda-menu org-agenda-mode-map "Agenda menu"
4353 '("Agenda" 4416 '("Agenda"
4354 ("Agenda Files") 4417 ("Agenda Files")
@@ -6625,10 +6688,11 @@ With prefix ARG, realign all tags in headings in the current buffer."
6625 (completing-read "Tags: " 'org-tags-completion-function 6688 (completing-read "Tags: " 'org-tags-completion-function
6626 nil nil current 'org-tags-history))) 6689 nil nil current 'org-tags-history)))
6627 (while (string-match "[-+&]+" tags) 6690 (while (string-match "[-+&]+" tags)
6628 (setq tags (replace-match ":" t t tags))) 6691 (setq tags (replace-match ":" t t tags))))
6629 (unless (setq empty (string-match "\\`[\t ]*\\'" tags)) 6692 ;; FIXME: still optimize this byt not checking when JUST-ALIGN?
6630 (unless (string-match ":$" tags) (setq tags (concat tags ":"))) 6693 (unless (setq empty (string-match "\\`[\t ]*\\'" tags))
6631 (unless (string-match "^:" tags) (setq tags (concat ":" tags))))) 6694 (unless (string-match ":$" tags) (setq tags (concat tags ":")))
6695 (unless (string-match "^:" tags) (setq tags (concat ":" tags))))
6632 (if (equal current "") 6696 (if (equal current "")
6633 (progn 6697 (progn
6634 (end-of-line 1) 6698 (end-of-line 1)
@@ -7192,8 +7256,8 @@ use sequences."
7192 (mh-show-buffer-message-number)))) 7256 (mh-show-buffer-message-number))))
7193 7257
7194(defun org-mhe-get-header (header) 7258(defun org-mhe-get-header (header)
7195 "Return a header of the message in folder mode. This will create a 7259 "Return a header of the message in folder mode. This will create a
7196show buffer for the corresponding message. If you have a more clever 7260show buffer for the corresponding message. If you have a more clever
7197idea..." 7261idea..."
7198 (let* ((folder (org-mhe-get-message-folder)) 7262 (let* ((folder (org-mhe-get-message-folder))
7199 (num (org-mhe-get-message-num)) 7263 (num (org-mhe-get-message-num))
@@ -10454,10 +10518,11 @@ translations. There is currently no way for users to extend this.")
10454 (erase-buffer) 10518 (erase-buffer)
10455 (insert string) 10519 (insert string)
10456 (org-mode) 10520 (org-mode)
10457 ;; Find targets in comments and move them out of comments 10521 ;; Find targets in comments and move them out of comments,
10522 ;; but mark them as targets that should be invisible
10458 (goto-char (point-min)) 10523 (goto-char (point-min))
10459 (while (re-search-forward "^#.*?\\(<<<?[^>\r\n]+>>>?\\).*" nil t) 10524 (while (re-search-forward "^#.*?\\(<<<?[^>\r\n]+>>>?\\).*" nil t)
10460 (replace-match "\\1")) 10525 (replace-match "\\1(INVISIBLE)"))
10461 ;; Find matches for radio targets and turn them into links 10526 ;; Find matches for radio targets and turn them into links
10462 (goto-char (point-min)) 10527 (goto-char (point-min))
10463 (while (re-search-forward re-radio nil t) 10528 (while (re-search-forward re-radio nil t)
@@ -10475,12 +10540,34 @@ translations. There is currently no way for users to extend this.")
10475 (kill-buffer " org-mode-tmp") 10540 (kill-buffer " org-mode-tmp")
10476 rtn)) 10541 rtn))
10477 10542
10478(defun org-solidify-link-text (s) 10543(defun org-solidify-link-text (s &optional alist)
10479 "Take link text and make a safe target out of it." 10544 "Take link text and make a safe target out of it."
10480 (save-match-data 10545 (save-match-data
10481 (mapconcat 10546 (let* ((rtn
10482 'identity 10547 (mapconcat
10483 (org-split-string s "[ \t\r\n]+") "--"))) 10548 'identity
10549 (org-split-string s "[ \t\r\n]+") "--"))
10550 (a (assoc rtn alist)))
10551 (or (cdr a) rtn))))
10552
10553(defun org-convert-to-odd-levels ()
10554 "Convert an org-mode file with all levels allowed to one with odd levels.
10555This will leave level 1 alone, convert level 2 to level 3, level 3 to
10556level 5 etc."
10557 (interactive)
10558 (when (yes-or-no-p "Are you sure you want to globally change levels? ")
10559 (let ((org-odd-levels-only nil) n)
10560 (save-excursion
10561 (goto-char (point-min))
10562 (while (re-search-forward "^\\*\\*+" nil t)
10563 (setq n (1- (length (match-string 0))))
10564 (while (>= (setq n (1- n)) 0)
10565 (org-demote))
10566 (end-of-line 1))))))
10567
10568(defun org-tr-level (n)
10569 "Make N odd if required."
10570 (if org-odd-levels-only (1+ (/ n 2)) n))
10484 10571
10485(defvar org-last-level nil) ; dynamically scoped variable 10572(defvar org-last-level nil) ; dynamically scoped variable
10486 10573
@@ -10561,6 +10648,7 @@ underlined headlines. The default is 3."
10561 ;; This is a headline 10648 ;; This is a headline
10562 (progn 10649 (progn
10563 (setq level (- (match-end 1) (match-beginning 1)) 10650 (setq level (- (match-end 1) (match-beginning 1))
10651 level (org-tr-level level)
10564 txt (match-string 3 line) 10652 txt (match-string 3 line)
10565 todo 10653 todo
10566 (or (and (match-beginning 2) 10654 (or (and (match-beginning 2)
@@ -10599,7 +10687,7 @@ underlined headlines. The default is 3."
10599 (cond 10687 (cond
10600 ((string-match "^\\(\\*+\\)[ \t]*\\(.*\\)" line) 10688 ((string-match "^\\(\\*+\\)[ \t]*\\(.*\\)" line)
10601 ;; a Headline 10689 ;; a Headline
10602 (setq level (- (match-end 1) (match-beginning 1)) 10690 (setq level (org-tr-level (- (match-end 1) (match-beginning 1)))
10603 txt (match-string 2 line)) 10691 txt (match-string 2 line))
10604 (org-ascii-level-start level txt umax)) 10692 (org-ascii-level-start level txt umax))
10605 (t (insert line "\n")))) 10693 (t (insert line "\n"))))
@@ -10860,6 +10948,7 @@ headlines. The default is 3. Lower levels will become bulleted lists."
10860 (language org-export-default-language) 10948 (language org-export-default-language)
10861 (text nil) 10949 (text nil)
10862 (lang-words nil) 10950 (lang-words nil)
10951 (target-alist nil) tg
10863 (head-count 0) cnt 10952 (head-count 0) cnt
10864 (start 0) 10953 (start 0)
10865 ;; FIXME: The following returns always nil under XEmacs 10954 ;; FIXME: The following returns always nil under XEmacs
@@ -10923,11 +11012,13 @@ headlines. The default is 3. Lower levels will become bulleted lists."
10923 (progn 11012 (progn
10924 (insert (format "<H2>%s</H2>\n" (nth 3 lang-words))) 11013 (insert (format "<H2>%s</H2>\n" (nth 3 lang-words)))
10925 (insert "<ul>\n") 11014 (insert "<ul>\n")
11015 (setq lines
10926 (mapcar '(lambda (line) 11016 (mapcar '(lambda (line)
10927 (if (string-match org-todo-line-regexp line) 11017 (if (string-match org-todo-line-regexp line)
10928 ;; This is a headline 11018 ;; This is a headline
10929 (progn 11019 (progn
10930 (setq level (- (match-end 1) (match-beginning 1)) 11020 (setq level (- (match-end 1) (match-beginning 1))
11021 level (org-tr-level level)
10931 txt (save-match-data 11022 txt (save-match-data
10932 (org-html-expand 11023 (org-html-expand
10933 (match-string 3 line))) 11024 (match-string 3 line)))
@@ -10957,15 +11048,28 @@ headlines. The default is 3. Lower levels will become bulleted lists."
10957 (while (>= (setq cnt (1- cnt)) 0) 11048 (while (>= (setq cnt (1- cnt)) 0)
10958 (insert "</ul>")) 11049 (insert "</ul>"))
10959 (insert "\n"))) 11050 (insert "\n")))
11051 ;; Check for targets
11052 (while (string-match org-target-regexp line)
11053 (setq tg (match-string 1 line)
11054 line (replace-match
11055 (concat "@<span class=\"target\">" tg "@</span> ")
11056 t t line))
11057 (push (cons (org-solidify-link-text tg)
11058 (format "sec-%d" head-count))
11059 target-alist))
11060 (while (string-match "&lt;\\(&lt;\\)+\\|&gt;\\(&gt;\\)+" txt)
11061 (setq txt (replace-match "" t t txt)))
10960 (insert 11062 (insert
10961 (format 11063 (format
10962 (if todo 11064 (if todo
10963 "<li><a href=\"#sec-%d\"><span class=\"todo\">%s</span></a>\n" 11065 "<li><a href=\"#sec-%d\"><span class=\"todo\">%s</span></a>\n"
10964 "<li><a href=\"#sec-%d\">%s</a>\n") 11066 "<li><a href=\"#sec-%d\">%s</a>\n")
10965 head-count txt)) 11067 head-count txt))
11068
10966 (setq org-last-level level)) 11069 (setq org-last-level level))
10967 )))) 11070 )))
10968 lines) 11071 line)
11072 lines))
10969 (while (> org-last-level 0) 11073 (while (> org-last-level 0)
10970 (setq org-last-level (1- org-last-level)) 11074 (setq org-last-level (1- org-last-level))
10971 (insert "</ul>\n")) 11075 (insert "</ul>\n"))
@@ -11001,18 +11105,31 @@ headlines. The default is 3. Lower levels will become bulleted lists."
11001 11105
11002 11106
11003 ;; make targets to anchors 11107 ;; make targets to anchors
11004 (while (string-match "<<<?\\([^<>]*\\)>>>?[ \t]*\n?" line) 11108 (while (string-match "<<<?\\([^<>]*\\)>>>?\\((INVISIBLE)\\)?[ \t]*\n?" line)
11005 (setq line (replace-match 11109 (cond
11006 (concat "@<a name=\"" 11110 ((match-end 2)
11007 (org-solidify-link-text (match-string 1 line)) 11111 (setq line (replace-match
11008 "\">\\nbsp@</a>") 11112 (concat "@<a name=\""
11009 t t line))) 11113 (org-solidify-link-text (match-string 1 line))
11114 "\">\\nbsp@</a>")
11115 t t line)))
11116 ((and org-export-with-toc (equal (string-to-char line) ?*))
11117 (setq line (replace-match
11118 (concat "@<span class=\"target\">" (match-string 1 line) "@</span> ")
11119; (concat "@<i>" (match-string 1 line) "@</i> ")
11120 t t line)))
11121 (t
11122 (setq line (replace-match
11123 (concat "@<a name=\""
11124 (org-solidify-link-text (match-string 1 line))
11125 "\" class=\"target\">" (match-string 1 line) "@</a> ")
11126 t t line)))))
11010 ;; Replace internal links 11127 ;; Replace internal links
11011 (while (string-match org-bracket-link-regexp line) 11128 (while (string-match org-bracket-link-regexp line)
11012 (setq line (replace-match 11129 (setq line (replace-match
11013 (concat 11130 (concat
11014 "@<a href=\"#" 11131 "@<a href=\"#"
11015 (org-solidify-link-text (match-string 1 line)) 11132 (org-solidify-link-text (match-string 1 line) target-alist)
11016 "\">" 11133 "\">"
11017 (match-string (if (match-end 3) 3 1) line) 11134 (match-string (if (match-end 3) 3 1) line)
11018 "@</a>") 11135 "@</a>")
@@ -11087,7 +11204,7 @@ headlines. The default is 3. Lower levels will become bulleted lists."
11087 (cond 11204 (cond
11088 ((string-match "^\\(\\*+\\)[ \t]*\\(.*\\)" line) 11205 ((string-match "^\\(\\*+\\)[ \t]*\\(.*\\)" line)
11089 ;; This is a headline 11206 ;; This is a headline
11090 (setq level (- (match-end 1) (match-beginning 1)) 11207 (setq level (org-tr-level (- (match-end 1) (match-beginning 1)))
11091 txt (match-string 2 line)) 11208 txt (match-string 2 line))
11092 (if (<= level umax) (setq head-count (+ head-count 1))) 11209 (if (<= level umax) (setq head-count (+ head-count 1)))
11093 (when in-local-list 11210 (when in-local-list
@@ -11822,6 +11939,7 @@ a time), or the day by one (if it does not contain a time)."
11822(define-key org-mode-map "\C-c\C-xb" 'org-export-as-html-and-open) 11939(define-key org-mode-map "\C-c\C-xb" 'org-export-as-html-and-open)
11823(define-key org-mode-map "\C-c\C-x\C-b" 'org-export-as-html-and-open) 11940(define-key org-mode-map "\C-c\C-x\C-b" 'org-export-as-html-and-open)
11824 11941
11942(define-key org-mode-map "\C-c\C-x\C-k" 'org-cut-special)
11825(define-key org-mode-map "\C-c\C-x\C-w" 'org-cut-special) 11943(define-key org-mode-map "\C-c\C-x\C-w" 'org-cut-special)
11826(define-key org-mode-map "\C-c\C-x\M-w" 'org-copy-special) 11944(define-key org-mode-map "\C-c\C-x\M-w" 'org-copy-special)
11827(define-key org-mode-map "\C-c\C-x\C-y" 'org-paste-special) 11945(define-key org-mode-map "\C-c\C-x\C-y" 'org-paste-special)
@@ -12244,7 +12362,9 @@ See the individual commands for more information."
12244 ["Demote Heading" org-metaright (not (org-at-table-p))] 12362 ["Demote Heading" org-metaright (not (org-at-table-p))]
12245 ["Demote Subtree" org-shiftmetaright (not (org-at-table-p))] 12363 ["Demote Subtree" org-shiftmetaright (not (org-at-table-p))]
12246 "--" 12364 "--"
12247 ["Archive Subtree" org-archive-subtree t]) 12365 ["Archive Subtree" org-archive-subtree t]
12366 "--"
12367 ["Convert file to odd levels" org-convert-to-odd-levels t])
12248 "--" 12368 "--"
12249 ("TODO Lists" 12369 ("TODO Lists"
12250 ["TODO/DONE/-" org-todo t] 12370 ["TODO/DONE/-" org-todo t]