Mercurial > emacs
comparison lisp/textmodes/org.el @ 70064:28d6f65fa9e6
(org-insert-heading): Insert heading before current if at
beginning of line.
(org-todo, org-date): New faces.
(org-table-align): Make sure tooltip window contains full text.
(org-no-properties): New defsubst.
(org-set-font-lock-defaults): Use new faces.
author | Carsten Dominik <dominik@science.uva.nl> |
---|---|
date | Tue, 18 Apr 2006 06:34:24 +0000 |
parents | a186cf26482b |
children | f8b9335f0cad |
comparison
equal
deleted
inserted
replaced
70063:be502e8c29ea | 70064:28d6f65fa9e6 |
---|---|
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.23 | 8 ;; Version: 4.24 |
9 ;; | 9 ;; |
10 ;; This file is part of GNU Emacs. | 10 ;; This file is part of GNU Emacs. |
11 ;; | 11 ;; |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | 12 ;; GNU Emacs is free software; you can redistribute it and/or modify |
13 ;; it under the terms of the GNU General Public License as published by | 13 ;; it under the terms of the GNU General Public License as published by |
79 ;; excellent reference card made by Philip Rooke. This card can be found | 79 ;; excellent reference card made by Philip Rooke. This card can be found |
80 ;; in the etc/ directory of Emacs 22. | 80 ;; in the etc/ directory of Emacs 22. |
81 ;; | 81 ;; |
82 ;; Changes since version 4.00: | 82 ;; Changes since version 4.00: |
83 ;; --------------------------- | 83 ;; --------------------------- |
84 ;; Version 4.24 | |
85 ;; - Bug fixes. | |
86 ;; | |
84 ;; Version 4.23 | 87 ;; Version 4.23 |
85 ;; - Bug fixes. | 88 ;; - Bug fixes. |
86 ;; | 89 ;; |
87 ;; Version 4.22 | 90 ;; Version 4.22 |
88 ;; - Bug fixes. | 91 ;; - Bug fixes. |
177 (defvar calc-embedded-open-formula) ; defined by the calc package | 180 (defvar calc-embedded-open-formula) ; defined by the calc package |
178 (defvar font-lock-unfontify-region-function) ; defined by font-lock.el | 181 (defvar font-lock-unfontify-region-function) ; defined by font-lock.el |
179 | 182 |
180 ;;; Customization variables | 183 ;;; Customization variables |
181 | 184 |
182 (defvar org-version "4.23" | 185 (defvar org-version "4.24" |
183 "The version number of the file org.el.") | 186 "The version number of the file org.el.") |
184 (defun org-version () | 187 (defun org-version () |
185 (interactive) | 188 (interactive) |
186 (message "Org-mode version %s" org-version)) | 189 (message "Org-mode version %s" org-version)) |
187 | 190 |
230 :type 'boolean) | 233 :type 'boolean) |
231 | 234 |
232 (defcustom org-startup-align-all-tables nil | 235 (defcustom org-startup-align-all-tables nil |
233 "Non-nil means, align all tables when visiting a file. | 236 "Non-nil means, align all tables when visiting a file. |
234 This is useful when the column width in tables is forced with <N> cookies | 237 This is useful when the column width in tables is forced with <N> cookies |
235 in table fields. Such tables will look correct only after the first re-align." | 238 in table fields. Such tables will look correct only after the first re-align. |
239 This can also be configured on a per-file basis by adding one of | |
240 the following lines anywhere in the buffer: | |
241 #+STARTUP: align | |
242 #+STARTUP: noalign" | |
236 :group 'org-startup | 243 :group 'org-startup |
237 :type 'boolean) | 244 :type 'boolean) |
238 | 245 |
239 (defcustom org-startup-with-deadline-check nil | 246 (defcustom org-startup-with-deadline-check nil |
240 "Non-nil means, entering Org-mode will run the deadline check. | 247 "Non-nil means, entering Org-mode will run the deadline check. |
241 This means, if you start editing an org file, you will get an | 248 This means, if you start editing an org file, you will get an |
242 immediate reminder of any due deadlines. | 249 immediate reminder of any due deadlines. |
243 This can also be configured on a per-file basis by adding one of | 250 This can also be configured on a per-file basis by adding one of |
244 the following lines anywhere in the buffer: | 251 the following lines anywhere in the buffer: |
245 | |
246 #+STARTUP: dlcheck | 252 #+STARTUP: dlcheck |
247 #+STARTUP: nodlcheck" | 253 #+STARTUP: nodlcheck" |
248 :group 'org-startup | 254 :group 'org-startup |
249 :type 'boolean) | 255 :type 'boolean) |
250 | 256 |
394 "Non-nil means, skip even levels and only use odd levels for the outline. | 400 "Non-nil means, skip even levels and only use odd levels for the outline. |
395 This has the effect that two stars are being added/taken away in | 401 This has the effect that two stars are being added/taken away in |
396 promotion/demotion commands. It also influences how levels are | 402 promotion/demotion commands. It also influences how levels are |
397 handled by the exporters. | 403 handled by the exporters. |
398 Changing it requires restart of `font-lock-mode' to become effective | 404 Changing it requires restart of `font-lock-mode' to become effective |
399 for fontification also in regions already fontified." | 405 for fontification also in regions already fontified. |
406 You may also set this on a per-file basis by adding one of the following | |
407 lines to the buffer: | |
408 | |
409 #+STARTUP: odd | |
410 #+STARTUP: oddeven" | |
400 :group 'org-edit-structure | 411 :group 'org-edit-structure |
401 :group 'org-font-lock | 412 :group 'org-font-lock |
402 :type 'boolean) | 413 :type 'boolean) |
403 | 414 |
404 (defcustom org-adapt-indentation t | 415 (defcustom org-adapt-indentation t |
1122 closing date." | 1133 closing date." |
1123 :group 'org-todo | 1134 :group 'org-todo |
1124 :type 'boolean) | 1135 :type 'boolean) |
1125 | 1136 |
1126 (defgroup org-priorities nil | 1137 (defgroup org-priorities nil |
1127 "Keywords in Org-mode." | 1138 "Priorities in Org-mode." |
1128 :tag "Org Priorities" | 1139 :tag "Org Priorities" |
1129 :group 'org-todo) | 1140 :group 'org-todo) |
1130 | 1141 |
1131 (defcustom org-default-priority ?B | 1142 (defcustom org-default-priority ?B |
1132 "The default priority of TODO items. | 1143 "The default priority of TODO items. |
1177 moved to the new date." | 1188 moved to the new date." |
1178 :group 'org-time | 1189 :group 'org-time |
1179 :type 'boolean) | 1190 :type 'boolean) |
1180 | 1191 |
1181 (defgroup org-tags nil | 1192 (defgroup org-tags nil |
1182 "Options concerning startup of Org-mode." | 1193 "Options concerning tags in Org-mode." |
1183 :tag "Org Tags" | 1194 :tag "Org Tags" |
1184 :group 'org) | 1195 :group 'org) |
1185 | 1196 |
1186 (defcustom org-tags-column 48 | 1197 (defcustom org-tags-column 48 |
1187 "The column to which tags should be indented in a headline. | 1198 "The column to which tags should be indented in a headline. |
1901 This works by using the face `org-hide' for these stars. This | 1912 This works by using the face `org-hide' for these stars. This |
1902 face is white for a light background, and black for a dark | 1913 face is white for a light background, and black for a dark |
1903 background. You may have to customize the face `org-hide' to | 1914 background. You may have to customize the face `org-hide' to |
1904 make this work. | 1915 make this work. |
1905 Changing it requires restart of `font-lock-mode' to become effective | 1916 Changing it requires restart of `font-lock-mode' to become effective |
1906 also in regions already fontified." | 1917 also in regions already fontified. |
1918 You may also set this on a per-file basis by adding one of the following | |
1919 lines to the buffer: | |
1920 | |
1921 #+STARTUP: hidestars | |
1922 #+STARTUP: showstars" | |
1907 :group 'org-font-lock | 1923 :group 'org-font-lock |
1908 :type 'boolean) | 1924 :type 'boolean) |
1909 | 1925 |
1910 (defcustom org-fontify-done-headline nil | 1926 (defcustom org-fontify-done-headline nil |
1911 "Non-nil means, change the face of a headline if it is marked DONE. | 1927 "Non-nil means, change the face of a headline if it is marked DONE. |
2068 (((class color) (background dark)) (:foreground "Cyan" :underline t)) | 2084 (((class color) (background dark)) (:foreground "Cyan" :underline t)) |
2069 (t (:bold t))) | 2085 (t (:bold t))) |
2070 "Face for links." | 2086 "Face for links." |
2071 :group 'org-faces) | 2087 :group 'org-faces) |
2072 | 2088 |
2089 (defface org-date | |
2090 '((((type tty) (class color)) (:foreground "cyan" :weight bold)) | |
2091 (((class color) (background light)) (:foreground "Purple" :underline t)) | |
2092 (((class color) (background dark)) (:foreground "Cyan" :underline t)) | |
2093 (t (:bold t))) | |
2094 "Face for links." | |
2095 :group 'org-faces) | |
2096 | |
2073 (defface org-tag | 2097 (defface org-tag |
2074 '((((type tty) (class color)) (:weight bold)) | 2098 '((((type tty) (class color)) (:weight bold)) |
2075 (((class color) (background light)) (:weight bold)) | 2099 (((class color) (background light)) (:weight bold)) |
2076 (((class color) (background dark)) (:weight bold)) | 2100 (((class color) (background dark)) (:weight bold)) |
2077 (t (:bold t))) | 2101 (t (:bold t))) |
2078 "Face for tags." | 2102 "Face for tags." |
2103 :group 'org-faces) | |
2104 | |
2105 (defface org-todo ;; font-lock-warning-face | |
2106 '((((type tty) (class color)) (:foreground "red")) | |
2107 (((class color) (background light)) (:foreground "Red" :bold t)) | |
2108 (((class color) (background dark)) (:foreground "Red1" :bold t)) | |
2109 ; (((class color) (background dark)) (:foreground "Pink" :bold t)) | |
2110 (t (:inverse-video t :bold t))) | |
2111 "Face for TODO keywords." | |
2079 :group 'org-faces) | 2112 :group 'org-faces) |
2080 | 2113 |
2081 (defface org-done ;; font-lock-type-face | 2114 (defface org-done ;; font-lock-type-face |
2082 '((((type tty) (class color)) (:foreground "green")) | 2115 '((((type tty) (class color)) (:foreground "green")) |
2083 (((class color) (background light)) (:foreground "ForestGreen" :bold t)) | 2116 (((class color) (background light)) (:foreground "ForestGreen" :bold t)) |
2398 (let ((s (match-string num string))) | 2431 (let ((s (match-string num string))) |
2399 (remove-text-properties 0 (length s) org-rm-props s) | 2432 (remove-text-properties 0 (length s) org-rm-props s) |
2400 s) | 2433 s) |
2401 (match-string-no-properties num string))) | 2434 (match-string-no-properties num string))) |
2402 | 2435 |
2436 (defsubst org-no-properties (s) | |
2437 (remove-text-properties 0 (length s) org-rm-props s) | |
2438 s) | |
2439 | |
2403 (defun org-current-time () | 2440 (defun org-current-time () |
2404 "Current time, possibly rounded to `org-time-stamp-rounding-minutes'." | 2441 "Current time, possibly rounded to `org-time-stamp-rounding-minutes'." |
2405 (if (> org-time-stamp-rounding-minutes 0) | 2442 (if (> org-time-stamp-rounding-minutes 0) |
2406 (let ((r org-time-stamp-rounding-minutes) | 2443 (let ((r org-time-stamp-rounding-minutes) |
2407 (time (decode-time))) | 2444 (time (decode-time))) |
2528 t))) | 2565 t))) |
2529 | 2566 |
2530 (defun org-activate-bracket-links (limit) | 2567 (defun org-activate-bracket-links (limit) |
2531 "Run through the buffer and add overlays to bracketed links." | 2568 "Run through the buffer and add overlays to bracketed links." |
2532 (if (re-search-forward org-bracket-link-regexp limit t) | 2569 (if (re-search-forward org-bracket-link-regexp limit t) |
2533 (let* ((help (concat "LINK: " (org-match-string-no-properties 1))) | 2570 (let* ((help (concat "LINK: " |
2571 (org-match-string-no-properties 1))) | |
2572 ;; FIXME: above we should remove the escapes. | |
2534 (ip (list 'invisible 'org-link 'intangible t 'rear-nonsticky t | 2573 (ip (list 'invisible 'org-link 'intangible t 'rear-nonsticky t |
2535 'keymap org-mouse-map 'mouse-face 'highlight | 2574 'keymap org-mouse-map 'mouse-face 'highlight |
2536 'help-echo help)) | 2575 'help-echo help)) |
2537 (vp (list 'rear-nonsticky t | 2576 (vp (list 'rear-nonsticky t |
2538 'keymap org-mouse-map 'mouse-face 'highlight | 2577 'keymap org-mouse-map 'mouse-face 'highlight |
2676 (1 'org-table)) | 2715 (1 'org-table)) |
2677 (if (memq 'angle lk) '(org-activate-angle-links (0 'org-link t))) | 2716 (if (memq 'angle lk) '(org-activate-angle-links (0 'org-link t))) |
2678 (if (memq 'plain lk) '(org-activate-plain-links (0 'org-link t))) | 2717 (if (memq 'plain lk) '(org-activate-plain-links (0 'org-link t))) |
2679 (if (memq 'bracket lk) '(org-activate-bracket-links (0 'org-link t))) | 2718 (if (memq 'bracket lk) '(org-activate-bracket-links (0 'org-link t))) |
2680 (if (memq 'radio lk) '(org-activate-target-links (0 'org-link t))) | 2719 (if (memq 'radio lk) '(org-activate-target-links (0 'org-link t))) |
2681 (if (memq 'date lk) '(org-activate-dates (0 'org-link t))) | 2720 (if (memq 'date lk) '(org-activate-dates (0 'org-date t))) |
2682 (if (memq 'camel lk) '(org-activate-camels (0 'org-link t))) | 2721 (if (memq 'camel lk) '(org-activate-camels (0 'org-link t))) |
2683 (if (memq 'tag lk) '(org-activate-tags (1 'org-tag prepend))) | 2722 (if (memq 'tag lk) '(org-activate-tags (1 'org-tag prepend))) |
2684 (if org-table-limit-column-width | 2723 (if org-table-limit-column-width |
2685 '(org-hide-wide-columns (0 nil append))) | 2724 '(org-hide-wide-columns (0 nil append))) |
2686 (list (concat "^\\*+[ \t]*" org-not-done-regexp) | 2725 (list (concat "^\\*+[ \t]*" org-not-done-regexp) |
2687 '(1 'org-warning t)) | 2726 '(1 'org-todo t)) |
2688 (list (concat "\\[#[A-Z]\\]") '(0 'org-special-keyword t)) | 2727 (list (concat "\\[#[A-Z]\\]") '(0 'org-special-keyword t)) |
2689 (list (concat "\\<" org-deadline-string) '(0 'org-special-keyword t)) | 2728 (list (concat "\\<" org-deadline-string) '(0 'org-special-keyword t)) |
2690 (list (concat "\\<" org-scheduled-string) '(0 'org-special-keyword t)) | 2729 (list (concat "\\<" org-scheduled-string) '(0 'org-special-keyword t)) |
2691 (list (concat "\\<" org-closed-string) '(0 'org-special-keyword t)) | 2730 (list (concat "\\<" org-closed-string) '(0 'org-special-keyword t)) |
2692 (if em '("\\(\\W\\|^\\)\\(\\*\\w+\\*\\)\\(\\W\\|$\\)" 2 'bold prepend)) | 2731 (if em '("\\(\\W\\|^\\)\\(\\*\\w+\\*\\)\\(\\W\\|$\\)" 2 'bold prepend)) |
2703 '(1 'org-done t))) | 2742 '(1 'org-done t))) |
2704 '("^[ \t]*\\(:.*\\)" (1 'org-table t)) | 2743 '("^[ \t]*\\(:.*\\)" (1 'org-table t)) |
2705 '("| *\\(:?=[^|\n]*\\)" (1 'org-formula t)) | 2744 '("| *\\(:?=[^|\n]*\\)" (1 'org-formula t)) |
2706 '("^[ \t]*| *\\([#!$*_^]\\) *|" (1 'org-formula t)) | 2745 '("^[ \t]*| *\\([#!$*_^]\\) *|" (1 'org-formula t)) |
2707 (if org-format-transports-properties-p | 2746 (if org-format-transports-properties-p |
2708 '("| *\\(<[0-9]+>\\) *|" (1 'org-formula t))) | 2747 '("| *\\(<[0-9]+>\\) *" (1 'org-formula t))) |
2709 ))) | 2748 ))) |
2710 (setq org-font-lock-extra-keywords (delq nil org-font-lock-extra-keywords)) | 2749 (setq org-font-lock-extra-keywords (delq nil org-font-lock-extra-keywords)) |
2711 ;; Now set the full font-lock-keywords | 2750 ;; Now set the full font-lock-keywords |
2712 (set (make-local-variable 'org-font-lock-keywords) | 2751 (set (make-local-variable 'org-font-lock-keywords) |
2713 org-font-lock-extra-keywords) | 2752 org-font-lock-extra-keywords) |
3068 (condition-case nil | 3107 (condition-case nil |
3069 (org-back-to-heading) | 3108 (org-back-to-heading) |
3070 (error (outline-next-heading))) | 3109 (error (outline-next-heading))) |
3071 (prog1 (match-string 0) | 3110 (prog1 (match-string 0) |
3072 (funcall outline-level))))) | 3111 (funcall outline-level))))) |
3073 (unless (bolp) (newline)) | 3112 (if (and (bolp) |
3113 (save-excursion (backward-char 1) (not (org-invisible-p)))) | |
3114 (open-line 1) | |
3115 (newline)) | |
3074 (insert head) | 3116 (insert head) |
3075 (if (looking-at "[ \t]*") | 3117 (if (looking-at "[ \t]*") |
3076 (replace-match " ")) | 3118 (replace-match " ")) |
3077 (run-hooks 'org-insert-heading-hook)))) | 3119 (run-hooks 'org-insert-heading-hook)))) |
3078 | 3120 |
6249 (if buffer-file-name | 6291 (if buffer-file-name |
6250 (file-name-sans-extension | 6292 (file-name-sans-extension |
6251 (file-name-nondirectory buffer-file-name)) | 6293 (file-name-nondirectory buffer-file-name)) |
6252 ""))) | 6294 ""))) |
6253 (tag (if tags (nth (1- (length tags)) tags) "")) | 6295 (tag (if tags (nth (1- (length tags)) tags) "")) |
6254 ;;(tag (or (nth (1- (or (length tags) 0)) tags) "")) FIXME: rm | |
6255 time ;; needed for the eval of the prefix format | 6296 time ;; needed for the eval of the prefix format |
6256 (ts (if dotime (concat (if (stringp dotime) dotime "") txt))) | 6297 (ts (if dotime (concat (if (stringp dotime) dotime "") txt))) |
6257 (time-of-day (and dotime (org-get-time-of-day ts))) | 6298 (time-of-day (and dotime (org-get-time-of-day ts))) |
6258 stamp plain s0 s1 s2 rtn) | 6299 stamp plain s0 s1 s2 rtn) |
6259 (when (and dotime time-of-day org-prefix-has-time) | 6300 (when (and dotime time-of-day org-prefix-has-time) |
7304 (if (or (not org-confirm-shell-links) | 7345 (if (or (not org-confirm-shell-links) |
7305 (funcall org-confirm-shell-links | 7346 (funcall org-confirm-shell-links |
7306 (format "Execute \"%s\" in shell? " | 7347 (format "Execute \"%s\" in shell? " |
7307 (org-add-props cmd nil | 7348 (org-add-props cmd nil |
7308 'face 'org-warning)))) | 7349 'face 'org-warning)))) |
7309 (shell-command cmd) | 7350 (progn |
7351 (message "Executing %s..." cmd) | |
7352 (shell-command cmd) | |
7353 (message "Executing %s...done" cmd)) | |
7310 (error "Abort")))) | 7354 (error "Abort")))) |
7311 | 7355 |
7312 (t | 7356 (t |
7313 (browse-url-at-point)))))) | 7357 (browse-url-at-point)))))) |
7314 | 7358 |
8663 (loop for xx in column do | 8707 (loop for xx in column do |
8664 (when (and (stringp xx) | 8708 (when (and (stringp xx) |
8665 (> (org-string-width xx) fmax)) | 8709 (> (org-string-width xx) fmax)) |
8666 (org-add-props xx nil | 8710 (org-add-props xx nil |
8667 'help-echo | 8711 'help-echo |
8668 (concat "Clipped table field, use C-c ` to edit. Full value is:\n" (copy-sequence xx))) | 8712 (concat "Clipped table field, use C-c ` to edit. Full value is:\n" (org-no-properties (copy-sequence xx)))) |
8669 (setq f1 (min fmax (or (string-match org-bracket-link-regexp xx) fmax))) | 8713 (setq f1 (min fmax (or (string-match org-bracket-link-regexp xx) fmax))) |
8670 (unless (> f1 1) | 8714 (unless (> f1 1) |
8671 (error "Cannot narrow field starting with wide link \"%s\"" | 8715 (error "Cannot narrow field starting with wide link \"%s\"" |
8672 (match-string 0 xx))) | 8716 (match-string 0 xx))) |
8673 (add-text-properties f1 (length xx) (list 'org-cwidth t) xx) | 8717 (add-text-properties f1 (length xx) (list 'org-cwidth t) xx) |
11763 (setq rpl (if (and org-export-html-inline-images | 11807 (setq rpl (if (and org-export-html-inline-images |
11764 file-is-image-p) | 11808 file-is-image-p) |
11765 (concat "<img src=\"" thefile "\"/>") | 11809 (concat "<img src=\"" thefile "\"/>") |
11766 (concat "<a href=\"" thefile "\">" desc "</a>"))))) | 11810 (concat "<a href=\"" thefile "\">" desc "</a>"))))) |
11767 ((member type '("bbdb" "vm" "wl" "mhe" "rmail" "gnus" "shell")) | 11811 ((member type '("bbdb" "vm" "wl" "mhe" "rmail" "gnus" "shell")) |
11768 (setq rpl (concat "<i><" type ":" path "></i>")))) | 11812 (setq rpl (concat "<i><" type ":" |
11769 ;; FIXME: We get to see the escaped links!!!!! | 11813 (save-match-data (org-link-unescape path)) |
11814 "></i>")))) | |
11770 (setq line (replace-match rpl t t line) | 11815 (setq line (replace-match rpl t t line) |
11771 start (+ start (length rpl)))) | 11816 start (+ start (length rpl)))) |
11772 ;; TODO items | 11817 ;; TODO items |
11773 (if (and (string-match org-todo-line-regexp line) | 11818 (if (and (string-match org-todo-line-regexp line) |
11774 (match-beginning 2)) | 11819 (match-beginning 2)) |