aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Dominik2006-02-22 07:10:21 +0000
committerCarsten Dominik2006-02-22 07:10:21 +0000
commita96ee7dff6592a3a12aa83d28a013cfa1265713b (patch)
treef76ce837c215b8ea380b8f1eb104194f222fa172
parent608c89a921fa0f2bf13a588f110826990446432f (diff)
downloademacs-a96ee7dff6592a3a12aa83d28a013cfa1265713b.tar.gz
emacs-a96ee7dff6592a3a12aa83d28a013cfa1265713b.zip
(org-mark-ring-previous, org-mark-ring-set): New
commands. (org-mark-ring): New variable. (org-mark-ring-length): New option. (org-open-at-point, org-goto, org-open-file): Push old position onto the mark ring. (org-add-hook): New function. (org-export-table-remove-special-lines): New option. (org-skip-comments, org-format-org-table-html): Respect new option `org-export-table-remove-special-lines'. (org-open-file): Allow special command configuration for directory link. (org-file-apps): Fixed bugs in customize type, added setting for directories. (org-activate-tags, org-format-agenda-item, org-complete) (org-get-tags-at, org-scan-tags, org-make-tags-matcher) (org-get-tags, org-get-buffer-tags, org-open-at-point) (org-link-search, org-make-org-heading-search-string) (org-make-org-heading-camel): Allow @ and 0-9 as tags characters. (org-radio-targets, org-file-link-context-use-camel-case) (org-activate-camels): New options. (org-update-radio-target-regexp, org-all-targets) (org-make-target-link-regexp, org-activate-target-links): New functions. (org-make-org-heading-search-string): New function. (org-store-link, org-insert-link): Use new option `org-file-link-context-use-camel-case'. (org-activate-camels): Use new option `org-activate-camels'. (org-link-regexp): Added mhe prefix. (org-open-at-point,org-store-link): Support for mhe links. (org-mhe-get-message-id, org-mhe-get-message-folder) (org-mhe-get-header,org-follow-mhe-link): New functions. (org-remove-angle-brackets, org-add-angle-brackets): New functions. (org-bracked-link-regexp): New constant. (org-read-date): Fixed bug that was rejecting all typed dates. (org-link-search): Make hierarchy above visible after a match. (org-follow-bbdb-link): Inhibit electric mode for BBDB. (org-store-link): Fixed bug with link creation when cursor is in an empty line. (org-open-at-point): Fixed bug with matching a link. Fixed buggy argument sequence in call to `org-view-tags'. (org-compile-prefix-format): Set `org-prefix-has-tag'. (org-prefix-has-tag): New variable. (org-format-agenda-item): Remove tags from headline if appropriate. (org-agenda-remove-tags-when-in-prefix): New option.
-rw-r--r--lisp/textmodes/org.el701
1 files changed, 577 insertions, 124 deletions
diff --git a/lisp/textmodes/org.el b/lisp/textmodes/org.el
index 3c70314703b..4b62eeb87a7 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.04 8;; Version: 4.05
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
@@ -81,6 +81,17 @@
81;; 81;;
82;; Changes since version 4.00: 82;; Changes since version 4.00:
83;; --------------------------- 83;; ---------------------------
84;; Version 4.05
85;; - Changes to internal link system (thanks to David Wainberg for ideas).
86;; - in-file links: [[Search String]] instead of <file:::Search String>
87;; - automatic links to "radio targets".
88;; - CamelCase not longer active by default, configure org-activate-camels
89;; if you want to turn it back on.
90;; - After following a link, `C-c &' jumps back to it.
91;; - MH-E link support (thanks to Thomas Baumann).
92;; - Special table lines are no longer exported.
93;; - Bug fixes and minor improvements.
94;;
84;; Version 4.04 95;; Version 4.04
85;; - Cleanup tags display in agenda. 96;; - Cleanup tags display in agenda.
86;; - Bug fixes. 97;; - Bug fixes.
@@ -115,7 +126,7 @@
115 126
116;;; Customization variables 127;;; Customization variables
117 128
118(defvar org-version "4.04" 129(defvar org-version "4.05"
119 "The version number of the file org.el.") 130 "The version number of the file org.el.")
120(defun org-version () 131(defun org-version ()
121 (interactive) 132 (interactive)
@@ -775,7 +786,7 @@ as possible."
775(defcustom org-level-color-stars-only nil 786(defcustom org-level-color-stars-only nil
776 "Non-nil means fontify only the stars in each headline. 787 "Non-nil means fontify only the stars in each headline.
777When nil, the entire headline is fontified. 788When nil, the entire headline is fontified.
778Changing it requires a restart of Emacs to become effective." 789Changing it requires restart of Emacs to become effective."
779 :group 'org-structure 790 :group 'org-structure
780 :type 'boolean) 791 :type 'boolean)
781 792
@@ -930,6 +941,12 @@ Needs to be set before org.el is loaded."
930 :group 'org-link 941 :group 'org-link
931 :type 'boolean) 942 :type 'boolean)
932 943
944(defcustom org-mark-ring-length 4
945 "Number of different positions to be recorded in the ring
946Changing this requires a restart of Emacs to work correctly."
947 :group 'org-link
948 :type 'interger)
949
933(defcustom org-link-format "<%s>" 950(defcustom org-link-format "<%s>"
934 "Default format for linkes in the buffer. 951 "Default format for linkes in the buffer.
935This is a format string for printf, %s will be replaced by the link text. 952This is a format string for printf, %s will be replaced by the link text.
@@ -948,13 +965,27 @@ recommend an additional URL: prefix, so the format would be \"<URL:%s>\"."
948When nil, it becomes possible to put several links into a line. 965When nil, it becomes possible to put several links into a line.
949Note that in tables, a link never extends accross fields, so in a table 966Note that in tables, a link never extends accross fields, so in a table
950it is always possible to put several links into a line. 967it is always possible to put several links into a line.
951Changing this variable requires a restart of Emacs to become effective." 968Changing this variable requires a restart of Emacs of become effective."
969 :group 'org-link
970 :type 'boolean)
971
972(defcustom org-radio-targets t
973 "Non-nil means activate text matching a link target.
974Radio targets are strings in triple angular brackets, like <<<My Target>>>.
975When this option is set, any occurrence of \"my target\" in normal text
976becomes a link."
977 :group 'org-link
978 :type 'boolean)
979
980(defcustom org-activate-camels nil
981 "Non-nil means, treat words in CamelCase as in-file links.
982Changing this requires restart of Emacs to become effective."
952 :group 'org-link 983 :group 'org-link
953 :type 'boolean) 984 :type 'boolean)
954 985
955(defcustom org-context-in-file-links t 986(defcustom org-context-in-file-links t
956 "Non-nil means, file links from `org-store-link' contain context. 987 "Non-nil means, file links from `org-store-link' contain context.
957The line number will be added to the file name with :: as separator and 988A search string will be added to the file name with :: as separator and
958used to find the context when the link is activated by the command 989used to find the context when the link is activated by the command
959`org-open-at-point'. 990`org-open-at-point'.
960Using a prefix arg to the command \\[org-store-link] (`org-store-link') 991Using a prefix arg to the command \\[org-store-link] (`org-store-link')
@@ -962,6 +993,12 @@ negates this setting for the duration of the command."
962 :group 'org-link 993 :group 'org-link
963 :type 'boolean) 994 :type 'boolean)
964 995
996(defcustom org-file-link-context-use-camel-case nil
997 "Non-nil means, use CamelCase to store a search context in a file link.
998When nil, the search string simply consists of the words of the string."
999 :group 'org-link
1000 :type 'boolean)
1001
965(defcustom org-keep-stored-link-after-insertion nil 1002(defcustom org-keep-stored-link-after-insertion nil
966 "Non-nil means, keep link in list for entire session. 1003 "Non-nil means, keep link in list for entire session.
967 1004
@@ -1082,13 +1119,15 @@ For more examples, see the system specific constants
1082`org-file-apps-defaults-gnu'." 1119`org-file-apps-defaults-gnu'."
1083 :group 'org-link 1120 :group 'org-link
1084 :type '(repeat 1121 :type '(repeat
1085 (cons (string :tag "Extension") 1122 (cons (choice :value ""
1123 (string :tag "Extension")
1124 (const :tag "Default for unrecognized files" t)
1125 (const :tag "Links to a directory" directory))
1086 (choice :value "" 1126 (choice :value ""
1087 (const :tag "Visit with Emacs" 'emacs) 1127 (const :tag "Visit with Emacs" emacs)
1088 (const :tag "Use system default" 'default) 1128 (const :tag "Use system default" default)
1089 (string :tag "Command") 1129 (string :tag "Command")
1090 (sexp :tag "Lisp form"))))) 1130 (sexp :tag "Lisp form")))))
1091
1092 1131
1093(defgroup org-remember nil 1132(defgroup org-remember nil
1094 "Options concerning interaction with remember.el." 1133 "Options concerning interaction with remember.el."
@@ -1508,6 +1547,15 @@ This option can also be set with the +OPTIONS line, e.g. \"|:nil\"."
1508 :group 'org-export 1547 :group 'org-export
1509 :type 'boolean) 1548 :type 'boolean)
1510 1549
1550(defcustom org-export-table-remove-special-lines t
1551 "Remove special lines and marking characters in calculating tables.
1552This removes the special marking character column from tables that are set
1553up for spreadsheet calculations. It also removes the entire lines
1554marked with `!', `_', or `^'. The lines with `$' are kept, because
1555the values of constants may be useful to have."
1556 :group 'org-export
1557 :type 'boolean)
1558
1511(defcustom org-export-prefer-native-exporter-for-tables nil 1559(defcustom org-export-prefer-native-exporter-for-tables nil
1512 "Non-nil means, always export tables created with table.el natively. 1560 "Non-nil means, always export tables created with table.el natively.
1513Natively means, use the HTML code generator in table.el. 1561Natively means, use the HTML code generator in table.el.
@@ -1923,6 +1971,10 @@ When this is non-nil, the headline after the keyword is set to the
1923 (defvar gnus-group-name) 1971 (defvar gnus-group-name)
1924 (defvar gnus-article-current) 1972 (defvar gnus-article-current)
1925 (defvar w3m-current-url) 1973 (defvar w3m-current-url)
1974 (defvar mh-progs)
1975 (defvar mh-current-folder)
1976 (defvar mh-show-folder-buffer)
1977 (defvar mh-index-folder)
1926 (defvar org-selected-point) 1978 (defvar org-selected-point)
1927 (defvar calendar-mode-map) 1979 (defvar calendar-mode-map)
1928 (defvar remember-save-after-remembering) 1980 (defvar remember-save-after-remembering)
@@ -1981,17 +2033,11 @@ The following commands are available:
1981 'org-unfontify-region) 2033 'org-unfontify-region)
1982 ;; Activate before-change-function 2034 ;; Activate before-change-function
1983 (set (make-local-variable 'org-table-may-need-update) t) 2035 (set (make-local-variable 'org-table-may-need-update) t)
1984 (make-local-hook 'before-change-functions) ;; needed for XEmacs 2036 (org-add-hook 'before-change-functions 'org-before-change-function nil
1985 (add-hook 'before-change-functions 'org-before-change-function nil 2037 'local)
1986 'local)
1987 ;; FIXME: The following does not work because isearch-mode-end-hook
1988 ;; is called *before* the visibility overlays as removed.
1989 ;; There should be another hook then for me to be used.
1990;; (make-local-hook 'isearch-mode-end-hook) ;; needed for XEmacs
1991;; (add-hook 'isearch-mode-end-hook 'org-show-hierarchy-above nil
1992;; 'local)
1993 ;; Paragraphs and auto-filling 2038 ;; Paragraphs and auto-filling
1994 (org-set-autofill-regexps) 2039 (org-set-autofill-regexps)
2040 (org-update-radio-target-regexp)
1995 ;; Settings for Calc embedded mode 2041 ;; Settings for Calc embedded mode
1996 (set (make-local-variable 'calc-embedded-open-formula) "|\\|\n") 2042 (set (make-local-variable 'calc-embedded-open-formula) "|\\|\n")
1997 (set (make-local-variable 'calc-embedded-close-formula) "|\\|\n") 2043 (set (make-local-variable 'calc-embedded-close-formula) "|\\|\n")
@@ -2053,9 +2099,9 @@ The following commands are available:
2053(defconst org-link-regexp 2099(defconst org-link-regexp
2054 (if org-allow-space-in-links 2100 (if org-allow-space-in-links
2055 (concat 2101 (concat
2056 "\\(https?\\|ftp\\|mailto\\|file\\|news\\|bbdb\\|vm\\|wl\\|rmail\\|gnus\\|shell\\):\\([^" org-non-link-chars "]+[^ " org-non-link-chars "]\\)") 2102 "\\(https?\\|ftp\\|mailto\\|file\\|news\\|bbdb\\|vm\\|wl\\|mhe\\|rmail\\|gnus\\|shell\\):\\([^" org-non-link-chars "]+[^ " org-non-link-chars "]\\)")
2057 (concat 2103 (concat
2058 "\\(https?\\|ftp\\|mailto\\|file\\|news\\|bbdb\\|vm\\|wl\\|rmail\\|gnus\\|shell\\):\\([^ " org-non-link-chars "]+\\)") 2104 "\\(https?\\|ftp\\|mailto\\|file\\|news\\|bbdb\\|vm\\|wl\\|mhe\\|rmail\\|gnus\\|shell\\):\\([^ " org-non-link-chars "]+\\)")
2059 ) 2105 )
2060 "Regular expression for matching links.") 2106 "Regular expression for matching links.")
2061(defconst org-link-maybe-angles-regexp 2107(defconst org-link-maybe-angles-regexp
@@ -2065,6 +2111,10 @@ The following commands are available:
2065 (concat "\000" org-link-regexp "\000") 2111 (concat "\000" org-link-regexp "\000")
2066 "Matches a link and optionally surrounding angle brackets.") 2112 "Matches a link and optionally surrounding angle brackets.")
2067 2113
2114(defconst org-bracket-link-regexp
2115 "\\[\\[\\([^]]+\\)\\]\\(\\[\\([^]]+\\)\\]\\)?\\]"
2116 "Matches a link in double brackets.")
2117
2068(defconst org-ts-lengths 2118(defconst org-ts-lengths
2069 (cons (length (format-time-string (car org-time-stamp-formats))) 2119 (cons (length (format-time-string (car org-time-stamp-formats)))
2070 (length (format-time-string (cdr org-time-stamp-formats)))) 2120 (length (format-time-string (cdr org-time-stamp-formats))))
@@ -2092,6 +2142,15 @@ The following commands are available:
2092 'keymap org-mouse-map)) 2142 'keymap org-mouse-map))
2093 t))) 2143 t)))
2094 2144
2145(defun org-activate-links2 (limit)
2146 "Run through the buffer and add overlays to links."
2147 (if (re-search-forward org-bracket-link-regexp limit t)
2148 (progn
2149 (add-text-properties (match-beginning 0) (match-end 0)
2150 (list 'mouse-face 'highlight
2151 'keymap org-mouse-map))
2152 t)))
2153
2095(defun org-activate-dates (limit) 2154(defun org-activate-dates (limit)
2096 "Run through the buffer and add overlays to dates." 2155 "Run through the buffer and add overlays to dates."
2097 (if (re-search-forward org-tsr-regexp limit t) 2156 (if (re-search-forward org-tsr-regexp limit t)
@@ -2101,19 +2160,75 @@ The following commands are available:
2101 'keymap org-mouse-map)) 2160 'keymap org-mouse-map))
2102 t))) 2161 t)))
2103 2162
2163(defvar org-target-link-regexp nil
2164 "Regular expression matching radio targets in plain text.")
2165(defvar org-target-regexp "<<\\([^<>\n\r]+\\)>>"
2166 "Regular expression matching a link target.")
2167(defvar org-radio-target-regexp "<<<\\([^<>\n\r]+\\)>>>"
2168 "Regular expression matching a link target.")
2169
2170(defun org-activate-target-links (limit)
2171 "Run through the buffer and add overlays to target matches."
2172 (when org-radio-targets
2173 (let ((case-fold-search t))
2174 (if (re-search-forward org-target-link-regexp limit t)
2175 (progn
2176 (add-text-properties (match-beginning 0) (match-end 0)
2177 (list 'mouse-face 'highlight
2178 'keymap org-mouse-map
2179 'org-linked-text t))
2180 t)))))
2181
2182(defun org-update-radio-target-regexp ()
2183 "Find all radio targets in this file and update the regular expression."
2184 (interactive)
2185 (when org-radio-targets
2186 (setq org-target-link-regexp
2187 (org-make-target-link-regexp (org-all-targets 'radio)))
2188 (font-lock-mode -1)
2189 (font-lock-mode 1)))
2190
2191(defun org-all-targets (&optional radio)
2192 "Return a list of all targets in this file.
2193With optional argument RADIO, only find radio targets."
2194 (let ((re (if radio org-radio-target-regexp org-target-regexp))
2195 rtn)
2196 (save-excursion
2197 (goto-char (point-min))
2198 (while (re-search-forward re nil t)
2199 (add-to-list 'rtn (downcase (match-string-no-properties 1))))
2200 rtn)))
2201
2202(defun org-make-target-link-regexp (targets)
2203 "Make regular expression matching all strings in TARGETS.
2204The regular expression finds the targets also if there is a line break
2205between words."
2206 (concat
2207 "\\<\\("
2208 (mapconcat
2209 (lambda (x)
2210 (while (string-match " +" x)
2211 (setq x (replace-match "\\s-+" t t x)))
2212 x)
2213 targets
2214 "\\|")
2215 "\\)\\>"))
2216
2104(defvar org-camel-regexp "\\*?\\<[A-Z]+[a-z]+[A-Z][a-zA-Z]*\\>" 2217(defvar org-camel-regexp "\\*?\\<[A-Z]+[a-z]+[A-Z][a-zA-Z]*\\>"
2105 "Matches CamelCase words, possibly with a star before it.") 2218 "Matches CamelCase words, possibly with a star before it.")
2219
2106(defun org-activate-camels (limit) 2220(defun org-activate-camels (limit)
2107 "Run through the buffer and add overlays to dates." 2221 "Run through the buffer and add overlays to dates."
2108 (if (re-search-forward org-camel-regexp limit t) 2222 (if org-activate-camels
2109 (progn 2223 (if (re-search-forward org-camel-regexp limit t)
2110 (add-text-properties (match-beginning 0) (match-end 0) 2224 (progn
2111 (list 'mouse-face 'highlight 2225 (add-text-properties (match-beginning 0) (match-end 0)
2112 'keymap org-mouse-map)) 2226 (list 'mouse-face 'highlight
2113 t))) 2227 'keymap org-mouse-map))
2228 t))))
2114 2229
2115(defun org-activate-tags (limit) 2230(defun org-activate-tags (limit)
2116 (if (re-search-forward "[ \t]\\(:[A-Za-z_:]+:\\)[ \r\n]" limit t) 2231 (if (re-search-forward "[ \t]\\(:[A-Za-z_@0-9:]+:\\)[ \r\n]" limit t)
2117 (progn 2232 (progn
2118 (add-text-properties (match-beginning 1) (match-end 1) 2233 (add-text-properties (match-beginning 1) (match-end 1)
2119 (list 'mouse-face 'highlight 2234 (list 'mouse-face 'highlight
@@ -2138,6 +2253,8 @@ The following commands are available:
2138 (let ((org-font-lock-extra-keywords 2253 (let ((org-font-lock-extra-keywords
2139 (list 2254 (list
2140 '(org-activate-links (0 'org-link t)) 2255 '(org-activate-links (0 'org-link t))
2256 '(org-activate-links2 (0 'org-link t))
2257 '(org-activate-target-links (0 'org-link t))
2141 '(org-activate-dates (0 'org-link t)) 2258 '(org-activate-dates (0 'org-link t))
2142 '(org-activate-camels (0 'org-link t)) 2259 '(org-activate-camels (0 'org-link t))
2143 '(org-activate-tags (1 'org-link t)) 2260 '(org-activate-tags (1 'org-link t))
@@ -2199,7 +2316,8 @@ The following commands are available:
2199 (inhibit-read-only t) (inhibit-point-motion-hooks t) 2316 (inhibit-read-only t) (inhibit-point-motion-hooks t)
2200 (inhibit-modification-hooks t) 2317 (inhibit-modification-hooks t)
2201 deactivate-mark buffer-file-name buffer-file-truename) 2318 deactivate-mark buffer-file-name buffer-file-truename)
2202 (remove-text-properties beg end '(mouse-face nil keymap nil)))) 2319 (remove-text-properties beg end
2320 '(mouse-face nil keymap nil org-linked-text nil))))
2203 2321
2204;;; Visibility cycling 2322;;; Visibility cycling
2205 2323
@@ -2433,8 +2551,10 @@ to the new location, making it and the headline hierarchy above it visible."
2433 (org-get-location (current-buffer) org-goto-help))) 2551 (org-get-location (current-buffer) org-goto-help)))
2434 (if selected-point 2552 (if selected-point
2435 (progn 2553 (progn
2554 (org-mark-ring-push org-goto-start-pos)
2436 (goto-char selected-point) 2555 (goto-char selected-point)
2437 (if (org-invisible-p) (org-show-hierarchy-above))) 2556 (if (or (org-invisible-p) (org-invisible-p2))
2557 (org-show-hierarchy-above)))
2438 (error "Quit")))) 2558 (error "Quit"))))
2439 2559
2440(defun org-get-location (buf help) 2560(defun org-get-location (buf help)
@@ -3213,7 +3333,7 @@ At all other locations, this simply calls `ispell-complete-word'."
3213 (let* ((end (point)) 3333 (let* ((end (point))
3214 (beg1 (save-excursion 3334 (beg1 (save-excursion
3215 (if (equal (char-before (point)) ?\ ) (backward-char 1)) 3335 (if (equal (char-before (point)) ?\ ) (backward-char 1))
3216 (skip-chars-backward "a-zA-Z_") 3336 (skip-chars-backward "a-zA-Z_@0-9")
3217 (point))) 3337 (point)))
3218 (beg (save-excursion 3338 (beg (save-excursion
3219 (if (equal (char-before (point)) ?\ ) (backward-char 1)) 3339 (if (equal (char-before (point)) ?\ ) (backward-char 1))
@@ -3247,7 +3367,11 @@ At all other locations, this simply calls `ispell-complete-word'."
3247 (save-excursion 3367 (save-excursion
3248 (goto-char (point-min)) 3368 (goto-char (point-min))
3249 (while (re-search-forward org-todo-line-regexp nil t) 3369 (while (re-search-forward org-todo-line-regexp nil t)
3250 (push (list (org-make-org-heading-camel (match-string 3))) 3370 (push (list
3371 (if org-file-link-context-use-camel-case
3372 (org-make-org-heading-camel (match-string 3) t)
3373 (org-make-org-heading-search-string
3374 (match-string 3) t)))
3251 tbl))) 3375 tbl)))
3252 tbl) 3376 tbl)
3253 (tag (setq type :tag beg beg1) 3377 (tag (setq type :tag beg beg1)
@@ -3475,9 +3599,8 @@ that the match should indeed be shown."
3475 (setq cnt (1+ cnt)) 3599 (setq cnt (1+ cnt))
3476 (org-highlight-new-match (match-beginning 0) (match-end 0)) 3600 (org-highlight-new-match (match-beginning 0) (match-end 0))
3477 (org-show-hierarchy-above)))) 3601 (org-show-hierarchy-above))))
3478 (make-local-hook 'before-change-functions) ; needed for XEmacs 3602 (org-add-hook 'before-change-functions 'org-remove-occur-highlights
3479 (add-hook 'before-change-functions 'org-remove-occur-highlights 3603 nil 'local)
3480 nil 'local)
3481 (run-hooks 'org-occur-hook) 3604 (run-hooks 'org-occur-hook)
3482 (if (interactive-p) 3605 (if (interactive-p)
3483 (message "%d match(es) for regexp %s" cnt regexp)) 3606 (message "%d match(es) for regexp %s" cnt regexp))
@@ -3488,7 +3611,8 @@ that the match should indeed be shown."
3488 (catch 'exit 3611 (catch 'exit
3489 (if (org-on-heading-p t) 3612 (if (org-on-heading-p t)
3490 (org-flag-heading nil) ; only show the heading 3613 (org-flag-heading nil) ; only show the heading
3491 (and (org-invisible-p) (org-show-hidden-entry))) ; show entire entry 3614 (and (or (org-invisible-p) (org-invisible-p2))
3615 (org-show-hidden-entry))) ; show entire entry
3492 (save-excursion 3616 (save-excursion
3493 (and org-show-following-heading 3617 (and org-show-following-heading
3494 (outline-next-heading) 3618 (outline-next-heading)
@@ -3765,7 +3889,8 @@ used to insert the time stamp into the buffer to include the time."
3765 (progn 3889 (progn
3766 (use-local-map map) 3890 (use-local-map map)
3767 (setq ans (read-string prompt "" nil nil)) 3891 (setq ans (read-string prompt "" nil nil))
3768 (setq ans (or ans1 ans2 ans))) 3892 (if (not (string-match "\\S-" ans)) (setq ans nil))
3893 (setq ans (or ans1 ans ans2)))
3769 (use-local-map old-map))))) 3894 (use-local-map old-map)))))
3770 ;; Naked prompt only 3895 ;; Naked prompt only
3771 (setq ans (read-string prompt "" nil timestr))) 3896 (setq ans (read-string prompt "" nil timestr)))
@@ -4133,10 +4258,8 @@ The following commands are available:
4133 (use-local-map org-agenda-mode-map) 4258 (use-local-map org-agenda-mode-map)
4134 (easy-menu-add org-agenda-menu) 4259 (easy-menu-add org-agenda-menu)
4135 (if org-startup-truncated (setq truncate-lines t)) 4260 (if org-startup-truncated (setq truncate-lines t))
4136 (make-local-hook 'post-command-hook) ; Needed for XEmacs 4261 (org-add-hook 'post-command-hook 'org-agenda-post-command-hook nil 'local)
4137 (add-hook 'post-command-hook 'org-agenda-post-command-hook nil 'local) 4262 (org-add-hook 'pre-command-hook 'org-unhighlight nil 'local)
4138 (make-local-hook 'pre-command-hook) ; Needed for XEmacs
4139 (add-hook 'pre-command-hook 'org-unhighlight nil 'local)
4140 (unless org-agenda-keep-modes 4263 (unless org-agenda-keep-modes
4141 (setq org-agenda-follow-mode nil 4264 (setq org-agenda-follow-mode nil
4142 org-agenda-show-log nil)) 4265 org-agenda-show-log nil))
@@ -5285,27 +5408,6 @@ the documentation of `org-diary'."
5285 (throw 'exit t))) 5408 (throw 'exit t)))
5286 nil))) 5409 nil)))
5287 5410
5288(defun org-get-tags-at (&optional pos)
5289 "Get a list of all headline targs applicable at POS.
5290POS defaults to point. If tags are inherited, the list contains
5291the targets in the same sequence as the headlines appear, i.e.
5292the tags of the current headline come last."
5293 (interactive)
5294 (let (tags)
5295 (save-excursion
5296 (goto-char (or pos (point)))
5297 (save-match-data
5298 (org-back-to-heading t)
5299 (condition-case nil
5300 (while t
5301 (if (looking-at "[^\r\n]+?:\\([a-zA-Z_:]+\\):[ \t]*\\([\n\r]\\|\\'\\)")
5302 (setq tags (append (org-split-string (match-string 1) ":") tags)))
5303 (or org-use-tag-inheritance (error ""))
5304 (org-up-heading-all 1))
5305 (error nil))))
5306 (message "%s" tags)
5307 tags))
5308
5309(defun org-agenda-get-todos () 5411(defun org-agenda-get-todos ()
5310 "Return the TODO information for agenda display." 5412 "Return the TODO information for agenda display."
5311 (let* ((props (list 'face nil 5413 (let* ((props (list 'face nil
@@ -5726,7 +5828,7 @@ only the correctly processes TXT should be returned - this is used by
5726 (when (and (or (eq org-agenda-remove-tags-when-in-prefix t) 5828 (when (and (or (eq org-agenda-remove-tags-when-in-prefix t)
5727 (and org-agenda-remove-tags-when-in-prefix 5829 (and org-agenda-remove-tags-when-in-prefix
5728 org-prefix-has-tag)) 5830 org-prefix-has-tag))
5729 (string-match ":[a-zA-Z_:]+:[ \t]*$" txt)) 5831 (string-match ":[a-zA-Z_@0-9:]+:[ \t]*$" txt))
5730 (setq txt (replace-match "" t t txt))) 5832 (setq txt (replace-match "" t t txt)))
5731 5833
5732 ;; Create the final string 5834 ;; Create the final string
@@ -6076,6 +6178,27 @@ the same tree node, and the headline of the tree node in the Org-mode file."
6076 (org-agenda-change-all-lines newhead hdmarker) 6178 (org-agenda-change-all-lines newhead hdmarker)
6077 (beginning-of-line 1))) 6179 (beginning-of-line 1)))
6078 6180
6181(defun org-get-tags-at (&optional pos)
6182 "Get a list of all headline targs applicable at POS.
6183POS defaults to point. If tags are inherited, the list contains
6184the targets in the same sequence as the headlines appear, i.e.
6185the tags of the current headline come last."
6186 (interactive)
6187 (let (tags)
6188 (save-excursion
6189 (goto-char (or pos (point)))
6190 (save-match-data
6191 (org-back-to-heading t)
6192 (condition-case nil
6193 (while t
6194 (if (looking-at "[^\r\n]+?:\\([a-zA-Z_@0-9:]+\\):[ \t]*\\([\n\r]\\|\\'\\)")
6195 (setq tags (append (org-split-string (match-string 1) ":") tags)))
6196 (or org-use-tag-inheritance (error ""))
6197 (org-up-heading-all 1))
6198 (error nil))))
6199 (message "%s" tags)
6200 tags))
6201
6079(defun org-agenda-set-tags () 6202(defun org-agenda-set-tags ()
6080 "Set tags for the current headline." 6203 "Set tags for the current headline."
6081 (interactive) 6204 (interactive)
@@ -6298,7 +6421,7 @@ are included in the output."
6298 (mapconcat 'regexp-quote 6421 (mapconcat 'regexp-quote
6299 (nreverse (cdr (reverse org-todo-keywords))) 6422 (nreverse (cdr (reverse org-todo-keywords)))
6300 "\\|") 6423 "\\|")
6301 "\\>\\)\\)? *\\(.*?\\)\\(:[A-Za-z_:]+:\\)?[ \t]*[\n\r]")) 6424 "\\>\\)\\)? *\\(.*?\\)\\(:[A-Za-z_@0-9:]+:\\)?[ \t]*[\n\r]"))
6302 (props (list 'face nil 6425 (props (list 'face nil
6303 'done-face 'org-done 6426 'done-face 'org-done
6304 'undone-face nil 6427 'undone-face nil
@@ -6386,7 +6509,7 @@ MATCH can contain positive and negative selection of tags, like
6386 (let ((match0 match) minus tag mm matcher orterms term orlist) 6509 (let ((match0 match) minus tag mm matcher orterms term orlist)
6387 (setq orterms (org-split-string match "|")) 6510 (setq orterms (org-split-string match "|"))
6388 (while (setq term (pop orterms)) 6511 (while (setq term (pop orterms))
6389 (while (string-match "^&?\\([-+:]\\)?\\([A-Za-z_]+\\)" term) 6512 (while (string-match "^&?\\([-+:]\\)?\\([A-Za-z_@0-9]+\\)" term)
6390 (setq minus (and (match-end 1) 6513 (setq minus (and (match-end 1)
6391 (equal (match-string 1 term) "-")) 6514 (equal (match-string 1 term) "-"))
6392 tag (match-string 2 term) 6515 tag (match-string 2 term)
@@ -6481,7 +6604,7 @@ With prefix ARG, realign all tags in headings in the current buffer."
6481 (re (concat "^" outline-regexp)) 6604 (re (concat "^" outline-regexp))
6482 (col (current-column)) 6605 (col (current-column))
6483 (current (org-get-tags)) 6606 (current (org-get-tags))
6484 tags hd empty) 6607 tags hd empty invis)
6485 (if arg 6608 (if arg
6486 (save-excursion 6609 (save-excursion
6487 (goto-char (point-min)) 6610 (goto-char (point-min))
@@ -6505,19 +6628,23 @@ With prefix ARG, realign all tags in headings in the current buffer."
6505 (if (equal current "") 6628 (if (equal current "")
6506 (progn 6629 (progn
6507 (end-of-line 1) 6630 (end-of-line 1)
6508 (or empty (insert " "))) 6631 (or empty (insert-before-markers " ")))
6509 (beginning-of-line 1) 6632 (beginning-of-line 1)
6633 (setq invis (org-invisible-p))
6510 (looking-at (concat "\\(.*\\)\\(" (regexp-quote current) "\\)[ \t]*")) 6634 (looking-at (concat "\\(.*\\)\\(" (regexp-quote current) "\\)[ \t]*"))
6511 (setq hd (match-string 1)) 6635 (setq hd (match-string 1))
6512 (delete-region (match-beginning 0) (match-end 0)) 6636 (delete-region (match-beginning 0) (match-end 0))
6513 (insert (org-trim hd) (if empty "" " "))) 6637 (insert-before-markers (org-trim hd) (if empty "" " ")))
6638 ;; FIXME: What happens when adding a new tag??? Seems OK!!!
6514 (unless (equal tags "") 6639 (unless (equal tags "")
6515 (move-to-column (max (current-column) 6640 (move-to-column (max (current-column)
6516 (if (> org-tags-column 0) 6641 (if (> org-tags-column 0)
6517 org-tags-column 6642 org-tags-column
6518 (- (- org-tags-column) (length tags)))) 6643 (- (- org-tags-column) (length tags))))
6519 t) 6644 t)
6520 (insert tags)) 6645 (insert-before-markers tags)
6646 (if (and (not invis) (org-invisible-p))
6647 (outline-flag-region (point-at-bol) (point) nil)))
6521 (move-to-column col)))) 6648 (move-to-column col))))
6522 6649
6523(defun org-tags-completion-function (string predicate &optional flag) 6650(defun org-tags-completion-function (string predicate &optional flag)
@@ -6551,7 +6678,7 @@ With prefix ARG, realign all tags in headings in the current buffer."
6551 (error "Not on a heading")) 6678 (error "Not on a heading"))
6552 (save-excursion 6679 (save-excursion
6553 (beginning-of-line 1) 6680 (beginning-of-line 1)
6554 (if (looking-at ".*[ \t]\\(:[A-Za-z_:]+:\\)[ \t]*\\(\r\\|$\\)") 6681 (if (looking-at ".*[ \t]\\(:[A-Za-z_@0-9:]+:\\)[ \t]*\\(\r\\|$\\)")
6555 (match-string 1) 6682 (match-string 1)
6556 ""))) 6683 "")))
6557 6684
@@ -6560,7 +6687,7 @@ With prefix ARG, realign all tags in headings in the current buffer."
6560 (let (tags) 6687 (let (tags)
6561 (save-excursion 6688 (save-excursion
6562 (goto-char (point-min)) 6689 (goto-char (point-min))
6563 (while (re-search-forward "[ \t]:\\([A-Za-z_:]+\\):[ \t\r\n]" nil t) 6690 (while (re-search-forward "[ \t]:\\([A-Za-z_@0-9:]+\\):[ \t\r\n]" nil t)
6564 (mapc (lambda (x) (add-to-list 'tags x)) 6691 (mapc (lambda (x) (add-to-list 'tags x))
6565 (org-split-string (match-string 1) ":")))) 6692 (org-split-string (match-string 1) ":"))))
6566 (mapcar 'list tags))) 6693 (mapcar 'list tags)))
@@ -6591,9 +6718,34 @@ optional argument IN-EMACS is non-nil, Emacs will visit the file."
6591 (org-agenda-list nil (time-to-days (org-time-string-to-time 6718 (org-agenda-list nil (time-to-days (org-time-string-to-time
6592 (substring (match-string 1) 0 10))) 6719 (substring (match-string 1) 0 10)))
6593 1) 6720 1)
6594 (let (type path line search (pos (point))) 6721 (let (type path link line search (pos (point)))
6595 (catch 'match 6722 (catch 'match
6596 (save-excursion 6723 (save-excursion
6724 (skip-chars-forward "^]\n\r")
6725 (when (and (re-search-backward "\\[\\[" nil t)
6726 (looking-at org-bracket-link-regexp)
6727 (<= (match-beginning 0) pos)
6728 (>= (match-end 0) pos))
6729 (setq link (match-string 1))
6730 (while (string-match " *\n *" link)
6731 (setq link (replace-match " " t t link)))
6732 (if (string-match org-link-regexp link)
6733 (setq type (match-string 1)
6734 path (match-string 2))
6735 (setq type "thisfile"
6736 path link))
6737 (throw 'match t)))
6738
6739 (when (get-text-property (point) 'org-linked-text)
6740 (setq type "thisfile"
6741 pos (if (get-text-property (1+ (point)) 'org-linked-text)
6742 (1+ (point)) (point))
6743 path (buffer-substring
6744 (previous-single-property-change pos 'org-linked-text)
6745 (next-single-property-change pos 'org-linked-text)))
6746 (throw 'match t))
6747
6748 (save-excursion
6597 (skip-chars-backward 6749 (skip-chars-backward
6598 (concat (if org-allow-space-in-links "^" "^ ") 6750 (concat (if org-allow-space-in-links "^" "^ ")
6599 org-non-link-chars)) 6751 org-non-link-chars))
@@ -6606,7 +6758,7 @@ optional argument IN-EMACS is non-nil, Emacs will visit the file."
6606 (throw 'match t))) 6758 (throw 'match t)))
6607 (save-excursion 6759 (save-excursion
6608 (skip-chars-backward "^ \t\n\r") 6760 (skip-chars-backward "^ \t\n\r")
6609 (when (looking-at "\\(:[A-Za-z_:]+\\):[ \t\r\n]") 6761 (when (looking-at "\\(:[A-Za-z_@0-9:]+\\):[ \t\r\n]")
6610 (setq type "tags" 6762 (setq type "tags"
6611 path (match-string 1)) 6763 path (match-string 1))
6612 (while (string-match ":" path) 6764 (while (string-match ":" path)
@@ -6614,7 +6766,8 @@ optional argument IN-EMACS is non-nil, Emacs will visit the file."
6614 (throw 'match t))) 6766 (throw 'match t)))
6615 (save-excursion 6767 (save-excursion
6616 (skip-chars-backward "a-zA-Z_") 6768 (skip-chars-backward "a-zA-Z_")
6617 (when (looking-at org-camel-regexp) 6769 (when (and org-activate-camels
6770 (looking-at org-camel-regexp))
6618 (setq type "camel" path (match-string 0)) 6771 (setq type "camel" path (match-string 0))
6619 (if (equal (char-before) ?*) 6772 (if (equal (char-before) ?*)
6620 (setq path (concat "*" path)))) 6773 (setq path (concat "*" path))))
@@ -6639,7 +6792,9 @@ optional argument IN-EMACS is non-nil, Emacs will visit the file."
6639 6792
6640 ((string= type "tags") 6793 ((string= type "tags")
6641 (org-tags-view in-emacs path)) 6794 (org-tags-view in-emacs path))
6642 ((string= type "camel") 6795 ((or (string= type "camel")
6796 (string= type "thisfile"))
6797 (org-mark-ring-push)
6643 (org-link-search 6798 (org-link-search
6644 path 6799 path
6645 (cond ((equal in-emacs '(4)) 'occur) 6800 (cond ((equal in-emacs '(4)) 'occur)
@@ -6686,6 +6841,14 @@ optional argument IN-EMACS is non-nil, Emacs will visit the file."
6686 article (match-string 3 path)) 6841 article (match-string 3 path))
6687 (org-follow-wl-link folder article))) 6842 (org-follow-wl-link folder article)))
6688 6843
6844 ((string= type "mhe")
6845 (let (folder article)
6846 (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
6847 (error "Error in MHE link"))
6848 (setq folder (match-string 1 path)
6849 article (match-string 3 path))
6850 (org-follow-mhe-link folder article)))
6851
6689 ((string= type "rmail") 6852 ((string= type "rmail")
6690 (let (folder article) 6853 (let (folder article)
6691 (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path)) 6854 (if (not (string-match "\\`\\([^#]+\\)\\(#\\(.*\\)\\)?" path))
@@ -6717,11 +6880,19 @@ sparse tree. In ordinary files, `occur' will be used to list matches.
6717If the current buffer is in `dired-mode', grep will be used to search 6880If the current buffer is in `dired-mode', grep will be used to search
6718in all files." 6881in all files."
6719 (let ((case-fold-search t) 6882 (let ((case-fold-search t)
6720 (s0 s) 6883 (s0 (mapconcat 'identity (org-split-string s "[ \t\r\n]+") " "))
6721 (pos (point)) 6884 (pos (point))
6722 (pre "") (post "") 6885 (pre "") (post "")
6723 words re0 re1 re2 re3 re4 re5 reall) 6886 words re0 re1 re2 re3 re4 re5 reall camel)
6724 (cond ((string-match "^/\\(.*\\)/$" s) 6887 (cond ((save-excursion
6888 (goto-char (point-min))
6889 (and
6890 (re-search-forward
6891 (concat "<<" (regexp-quote s0) ">>") nil t)
6892 (setq pos (match-beginning 0))))
6893 ;; There is an exact target for this
6894 (goto-char pos))
6895 ((string-match "^/\\(.*\\)/$" s)
6725 ;; A regular expression 6896 ;; A regular expression
6726 (cond 6897 (cond
6727 ((eq major-mode 'org-mode) 6898 ((eq major-mode 'org-mode)
@@ -6729,17 +6900,22 @@ in all files."
6729 ;;((eq major-mode 'dired-mode) 6900 ;;((eq major-mode 'dired-mode)
6730 ;; (grep (concat "grep -n -e '" (match-string 1 s) "' *"))) 6901 ;; (grep (concat "grep -n -e '" (match-string 1 s) "' *")))
6731 (t (org-do-occur (match-string 1 s))))) 6902 (t (org-do-occur (match-string 1 s)))))
6732 ((string-match (concat "^" org-camel-regexp) s) 6903 ((or (setq camel (string-match (concat "^" org-camel-regexp "$") s))
6733 ;; A camel 6904 t)
6734 (if (equal (string-to-char s) ?*) 6905 ;; A camel or a normal search string
6735 (setq pre "^\\*+[ \t]*\\(\\sw+\\)?[ \t]*" 6906 (when (equal (string-to-char s) ?*)
6736 post "[ \t]*$" 6907 ;; Anchor on headlines, post may include tags.
6737 s (substring s 1))) 6908 (setq pre "^\\*+[ \t]*\\(\\sw+\\)?[ \t]*"
6909 post "[ \t]*\\([ \t]+:[a-zA-Z_@0-9:+]:[ \t]*\\)?$"
6910 s (substring s 1)))
6738 (remove-text-properties 6911 (remove-text-properties
6739 0 (length s) 6912 0 (length s)
6740 '(face nil mouse-face nil keymap nil fontified nil) s) 6913 '(face nil mouse-face nil keymap nil fontified nil) s)
6741 ;; Make a series of regular expressions to find a match 6914 ;; Make a series of regular expressions to find a match
6742 (setq words (org-camel-to-words s) 6915 (setq words
6916 (if camel
6917 (org-camel-to-words s)
6918 (org-split-string s "[ \n\r\t]+"))
6743 re0 (concat "<<" (regexp-quote s0) ">>") 6919 re0 (concat "<<" (regexp-quote s0) ">>")
6744 re2 (concat "\\<" (mapconcat 'downcase words "[ \t]+") "\\>") 6920 re2 (concat "\\<" (mapconcat 'downcase words "[ \t]+") "\\>")
6745 re4 (concat "\\<" (mapconcat 'downcase words "[^a-zA-Z_\r\n]+") "\\>") 6921 re4 (concat "\\<" (mapconcat 'downcase words "[^a-zA-Z_\r\n]+") "\\>")
@@ -6770,7 +6946,8 @@ in all files."
6770 (goto-char (point-min)) 6946 (goto-char (point-min))
6771 (if (search-forward s nil t) 6947 (if (search-forward s nil t)
6772 (goto-char (match-beginning 0)) 6948 (goto-char (match-beginning 0))
6773 (error "No match")))))) 6949 (error "No match"))))
6950 (and (eq major-mode 'org-mode) (org-show-hierarchy-above))))
6774 6951
6775(defun org-do-occur (regexp &optional cleanup) 6952(defun org-do-occur (regexp &optional cleanup)
6776 "Call the Emacs command `occur'. 6953 "Call the Emacs command `occur'.
@@ -6791,6 +6968,47 @@ to read."
6791 (goto-char (point-min)) 6968 (goto-char (point-min))
6792 (select-window cwin)))) 6969 (select-window cwin))))
6793 6970
6971(defvar org-mark-ring nil
6972 "Mark ring for positions before jumps in Org-mode.")
6973(defvar org-mark-ring-last-goto nil
6974 "Last position in the mark ring used to go back.")
6975;; Fill and close the ring
6976(setq org-mark-ring nil org-mark-ring-last-goto nil) ;; in case file is reloaded
6977(loop for i from 1 to org-mark-ring-length do
6978 (push (make-marker) org-mark-ring))
6979(setcdr (nthcdr (1- org-mark-ring-length) org-mark-ring)
6980 org-mark-ring)
6981
6982(defun org-mark-ring-push (&optional pos buffer)
6983 "Put the current position or POS into the mark ring and rotate it."
6984 (interactive)
6985 (setq pos (or pos (point)))
6986 (setq org-mark-ring (nthcdr (1- org-mark-ring-length) org-mark-ring))
6987 (move-marker (car org-mark-ring)
6988 (or pos (point))
6989 (or buffer (current-buffer)))
6990 (message
6991 (substitute-command-keys
6992 "Position saved to mark ring, go back with \\[org-mark-ring-goto].")))
6993
6994(defun org-mark-ring-goto (&optional n)
6995 "Jump to the previous position in the mark ring.
6996With prefix arg N, jump back that many stored positions. When
6997called several times in succession, walk through the entire ring.
6998Org-mode commands jumping to a different position in the current file,
6999or to another Org-mode file, automatically push the old position
7000onto the ring."
7001 (interactive "p")
7002 (let (p m)
7003 (if (eq last-command this-command)
7004 (setq p (nthcdr n (or org-mark-ring-last-goto org-mark-ring)))
7005 (setq p org-mark-ring))
7006 (setq org-mark-ring-last-goto p)
7007 (setq m (car p))
7008 (switch-to-buffer (marker-buffer m))
7009 (goto-char m)
7010 (if (or (org-invisible-p) (org-invisible-p2)) (org-show-hierarchy-above))))
7011
6794(defun org-camel-to-words (s) 7012(defun org-camel-to-words (s)
6795 "Split \"CamelCaseWords\" to (\"Camel\" \"Case\" \"Words\")." 7013 "Split \"CamelCaseWords\" to (\"Camel\" \"Case\" \"Words\")."
6796 (let ((case-fold-search nil) 7014 (let ((case-fold-search nil)
@@ -6800,10 +7018,20 @@ to read."
6800 (setq s (substring s (1+ (match-beginning 0))))) 7018 (setq s (substring s (1+ (match-beginning 0)))))
6801 (nreverse (cons s words)))) 7019 (nreverse (cons s words))))
6802 7020
7021(defun org-remove-angle-brackets (s)
7022 (if (equal (substring s 0 1) "<") (setq s (substring s 1)))
7023 (if (equal (substring s -1) ">") (setq s (substring s 0 -1)))
7024 s)
7025(defun org-add-angle-brackets (s)
7026 (if (equal (substring s 0 1) "<") nil (setq s (concat "<" s)))
7027 (if (equal (substring s -1) ">") nil (setq s (concat s ">")))
7028 s)
7029
6803(defun org-follow-bbdb-link (name) 7030(defun org-follow-bbdb-link (name)
6804 "Follow a BBDB link to NAME." 7031 "Follow a BBDB link to NAME."
6805 (require 'bbdb) 7032 (require 'bbdb)
6806 (let ((inhibit-redisplay t)) 7033 (let ((inhibit-redisplay t)
7034 (bbdb-electric-p nil))
6807 (catch 'exit 7035 (catch 'exit
6808 ;; Exact match on name 7036 ;; Exact match on name
6809 (bbdb-name (concat "\\`" name "\\'") nil) 7037 (bbdb-name (concat "\\`" name "\\'") nil)
@@ -6839,6 +7067,7 @@ to read."
6839(defun org-follow-vm-link (&optional folder article readonly) 7067(defun org-follow-vm-link (&optional folder article readonly)
6840 "Follow a VM link to FOLDER and ARTICLE." 7068 "Follow a VM link to FOLDER and ARTICLE."
6841 (require 'vm) 7069 (require 'vm)
7070 (setq article (org-add-angle-brackets article))
6842 (if (string-match "^//\\([a-zA-Z]+@\\)?\\([^:]+\\):\\(.*\\)" folder) 7071 (if (string-match "^//\\([a-zA-Z]+@\\)?\\([^:]+\\):\\(.*\\)" folder)
6843 ;; ange-ftp or efs or tramp access 7072 ;; ange-ftp or efs or tramp access
6844 (let ((user (or (match-string 1 folder) (user-login-name))) 7073 (let ((user (or (match-string 1 folder) (user-login-name)))
@@ -6872,12 +7101,14 @@ to read."
6872 7101
6873(defun org-follow-wl-link (folder article) 7102(defun org-follow-wl-link (folder article)
6874 "Follow a Wanderlust link to FOLDER and ARTICLE." 7103 "Follow a Wanderlust link to FOLDER and ARTICLE."
7104 (setq article (org-add-angle-brackets article))
6875 (wl-summary-goto-folder-subr folder 'no-sync t nil t) 7105 (wl-summary-goto-folder-subr folder 'no-sync t nil t)
6876 (if article (wl-summary-jump-to-msg-by-message-id article)) 7106 (if article (wl-summary-jump-to-msg-by-message-id article ">"))
6877 (wl-summary-redisplay)) 7107 (wl-summary-redisplay))
6878 7108
6879(defun org-follow-rmail-link (folder article) 7109(defun org-follow-rmail-link (folder article)
6880 "Follow an RMAIL link to FOLDER and ARTICLE." 7110 "Follow an RMAIL link to FOLDER and ARTICLE."
7111 (setq article (org-add-angle-brackets article))
6881 (let (message-number) 7112 (let (message-number)
6882 (save-excursion 7113 (save-excursion
6883 (save-window-excursion 7114 (save-window-excursion
@@ -6898,6 +7129,107 @@ to read."
6898 message-number) 7129 message-number)
6899 (error "Message not found")))) 7130 (error "Message not found"))))
6900 7131
7132;; mh-e integration based on planner-mode
7133(defun org-mhe-get-message-real-folder ()
7134 "Return the name of the current message real folder, so if you use
7135 sequences, it will now work."
7136 (save-excursion
7137 (let* ((folder
7138 (if (equal major-mode 'mh-folder-mode)
7139 mh-current-folder
7140 ;; Refer to the show buffer
7141 mh-show-folder-buffer))
7142 (end-index
7143 (if (boundp 'mh-index-folder)
7144 (min (length mh-index-folder) (length folder))))
7145 )
7146 ;; a simple test on mh-index-data does not work, because
7147 ;; mh-index-data is always nil in a show buffer.
7148 (if (and (boundp 'mh-index-folder)
7149 (string= mh-index-folder (substring folder 0 end-index)))
7150 (if (equal major-mode 'mh-show-mode)
7151 (save-window-excursion
7152 (when (buffer-live-p (get-buffer folder))
7153 (progn
7154 (pop-to-buffer folder)
7155 (org-mhe-get-message-folder-from-index)
7156 )
7157 ))
7158 (org-mhe-get-message-folder-from-index)
7159 )
7160 folder
7161 )
7162 )))
7163
7164(defun org-mhe-get-message-folder-from-index ()
7165 "Returns the name of the message folder in a index folder
7166 buffer."
7167 (save-excursion
7168 (mh-index-previous-folder)
7169 (if (not (re-search-forward "^\\(+.*\\)$" nil t))
7170 (message "Problem getting folder from index.")
7171 (message (match-string 1)))))
7172
7173(defun org-mhe-get-message-folder ()
7174 "Return the name of the current message folder. Be careful if you
7175 use sequences."
7176 (save-excursion
7177 (if (equal major-mode 'mh-folder-mode)
7178 mh-current-folder
7179 ;; Refer to the show buffer
7180 mh-show-folder-buffer)))
7181
7182(defun org-mhe-get-message-num ()
7183 "Return the number of the current message. Be careful if you
7184 use sequences."
7185 (save-excursion
7186 (if (equal major-mode 'mh-folder-mode)
7187 (mh-get-msg-num nil)
7188 ;; Refer to the show buffer
7189 (mh-show-buffer-message-number))))
7190
7191(defun org-mhe-get-header (header)
7192 "Return a header of the message in folder mode. This will create a
7193 show buffer for the corresponding message. If you have a more clever
7194 idea..."
7195 (let* ((folder (org-mhe-get-message-folder))
7196 (num (org-mhe-get-message-num))
7197 (buffer (get-buffer-create (concat "show-" folder)))
7198 (header-field))
7199 (with-current-buffer buffer
7200 (mh-display-msg num folder)
7201 (if (equal major-mode 'mh-folder-mode)
7202 (mh-header-display)
7203 (mh-show-header-display))
7204 (set-buffer buffer)
7205 (setq header-field (mh-get-header-field header))
7206 (if (equal major-mode 'mh-folder-mode)
7207 (mh-show)
7208 (mh-show-show))
7209 header-field)))
7210
7211(defun org-follow-mhe-link (folder article)
7212 "Follow an MHE link to FOLDER and ARTICLE."
7213 (setq article (org-add-angle-brackets article))
7214;; (require 'mh-e)
7215 (mh-rmail) ;; mh-e is standard with emacs 22
7216 (let* ((show-buf (concat "show-" folder)))
7217 (get-buffer-create show-buf)
7218 (mh-display-msg
7219 (string-to-number
7220 (car (split-string
7221 (with-temp-buffer
7222 (call-process
7223 (expand-file-name "pick" mh-progs)
7224 nil t nil
7225 folder
7226 "--message-id"
7227 article)
7228 (buffer-string))
7229 "\n")))
7230 folder)
7231 (pop-to-buffer show-buf)))
7232
6901(defun org-open-file (path &optional in-emacs line search) 7233(defun org-open-file (path &optional in-emacs line search)
6902 "Open the file at PATH. 7234 "Open the file at PATH.
6903First, this expands any special file name abbreviations. Then the 7235First, this expands any special file name abbreviations. Then the
@@ -6913,7 +7245,11 @@ If the file does not exist, an error is thrown."
6913 (let* ((file (if (equal path "") 7245 (let* ((file (if (equal path "")
6914 (buffer-file-name) 7246 (buffer-file-name)
6915 (convert-standard-filename (org-expand-file-name path)))) 7247 (convert-standard-filename (org-expand-file-name path))))
7248 (dirp (file-directory-p file))
6916 (dfile (downcase file)) 7249 (dfile (downcase file))
7250 (old-buffer (current-buffer))
7251 (old-pos (point))
7252 (old-mode major-mode)
6917 ext cmd apps) 7253 ext cmd apps)
6918 (if (and (not (file-exists-p file)) 7254 (if (and (not (file-exists-p file))
6919 (not org-open-non-existing-files)) 7255 (not org-open-non-existing-files))
@@ -6925,7 +7261,8 @@ If the file does not exist, an error is thrown."
6925 (setq apps (append org-file-apps (org-default-apps))) 7261 (setq apps (append org-file-apps (org-default-apps)))
6926 (if in-emacs 7262 (if in-emacs
6927 (setq cmd 'emacs) 7263 (setq cmd 'emacs)
6928 (setq cmd (or (cdr (assoc ext apps)) 7264 (setq cmd (or (and dirp (cdr (assoc 'directory apps)))
7265 (cdr (assoc ext apps))
6929 (cdr (assoc t apps))))) 7266 (cdr (assoc t apps)))))
6930 (when (eq cmd 'mailcap) 7267 (when (eq cmd 'mailcap)
6931 (require 'mailcap) 7268 (require 'mailcap)
@@ -6948,7 +7285,11 @@ If the file does not exist, an error is thrown."
6948 (if search (org-link-search search)))) 7285 (if search (org-link-search search))))
6949 ((consp cmd) 7286 ((consp cmd)
6950 (eval cmd)) 7287 (eval cmd))
6951 (t (funcall (cdr (assq 'file org-link-frame-setup)) file))))) 7288 (t (funcall (cdr (assq 'file org-link-frame-setup)) file)))
7289 (and (eq major-mode 'org-mode) (eq old-mode 'org-mode)
7290 (or (not (equal old-buffer (current-buffer)))
7291 (not (equal old-pos (point))))
7292 (org-mark-ring-push old-pos old-buffer))))
6952 7293
6953(defun org-default-apps () 7294(defun org-default-apps ()
6954 "Return the default applications for this operating system." 7295 "Return the default applications for this operating system."
@@ -6979,7 +7320,7 @@ For some link types, a prefix arg is interpreted:
6979For links to usenet articles, arg negates `org-usenet-links-prefer-google'. 7320For links to usenet articles, arg negates `org-usenet-links-prefer-google'.
6980For file links, arg negates `org-context-in-file-links'." 7321For file links, arg negates `org-context-in-file-links'."
6981 (interactive "P") 7322 (interactive "P")
6982 (let (link cpltxt) 7323 (let (link cpltxt txt (pos (point)))
6983 (cond 7324 (cond
6984 7325
6985 ((eq major-mode 'bbdb-mode) 7326 ((eq major-mode 'bbdb-mode)
@@ -7009,6 +7350,7 @@ For file links, arg negates `org-context-in-file-links'."
7009 (subject (vm-su-subject message)) 7350 (subject (vm-su-subject message))
7010 (author (vm-su-full-name message)) 7351 (author (vm-su-full-name message))
7011 (message-id (vm-su-message-id message))) 7352 (message-id (vm-su-message-id message)))
7353 (setq message-id (org-remove-angle-brackets message-id))
7012 (setq folder (abbreviate-file-name folder)) 7354 (setq folder (abbreviate-file-name folder))
7013 (if (string-match (concat "^" (regexp-quote vm-folder-directory)) 7355 (if (string-match (concat "^" (regexp-quote vm-folder-directory))
7014 folder) 7356 folder)
@@ -7026,12 +7368,25 @@ For file links, arg negates `org-context-in-file-links'."
7026 msgnum (wl-summary-buffer-msgdb))) 7368 msgnum (wl-summary-buffer-msgdb)))
7027 (author (wl-summary-line-from)) ; FIXME: how to get author name? 7369 (author (wl-summary-line-from)) ; FIXME: how to get author name?
7028 (subject "???")) ; FIXME: How to get subject of email? 7370 (subject "???")) ; FIXME: How to get subject of email?
7371 (setq message-id (org-remove-angle-brackets message-id))
7029 (setq cpltxt (concat author " on: " subject)) 7372 (setq cpltxt (concat author " on: " subject))
7030 (setq link (concat cpltxt "\n " 7373 (setq link (concat cpltxt "\n "
7031 (org-make-link 7374 (org-make-link
7032 "wl:" wl-summary-buffer-folder-name 7375 "wl:" wl-summary-buffer-folder-name
7033 "#" message-id))))) 7376 "#" message-id)))))
7034 7377
7378 ((or (equal major-mode 'mh-folder-mode)
7379 (equal major-mode 'mh-show-mode))
7380 (let ((from-header (org-mhe-get-header "From:"))
7381 (to-header (org-mhe-get-header "To:"))
7382 (subject (org-mhe-get-header "Subject:")))
7383 (setq cpltxt (concat from-header " on: " subject))
7384 (setq link (concat cpltxt "\n "
7385 (org-make-link
7386 "mhe:" (org-mhe-get-message-real-folder) "#"
7387 (org-remove-angle-brackets
7388 (org-mhe-get-header "Message-Id:")))))))
7389
7035 ((eq major-mode 'rmail-mode) 7390 ((eq major-mode 'rmail-mode)
7036 (save-excursion 7391 (save-excursion
7037 (save-restriction 7392 (save-restriction
@@ -7040,6 +7395,7 @@ For file links, arg negates `org-context-in-file-links'."
7040 (message-id (mail-fetch-field "message-id")) 7395 (message-id (mail-fetch-field "message-id"))
7041 (author (mail-fetch-field "from")) 7396 (author (mail-fetch-field "from"))
7042 (subject (mail-fetch-field "subject"))) 7397 (subject (mail-fetch-field "subject")))
7398 (setq message-id (org-remove-angle-brackets message-id))
7043 (setq cpltxt (concat author " on: " subject)) 7399 (setq cpltxt (concat author " on: " subject))
7044 (setq link (concat cpltxt "\n " 7400 (setq link (concat cpltxt "\n "
7045 (org-make-link 7401 (org-make-link
@@ -7093,19 +7449,26 @@ For file links, arg negates `org-context-in-file-links'."
7093 (abbreviate-file-name (buffer-file-name)))) 7449 (abbreviate-file-name (buffer-file-name))))
7094 ;; Add a context search string 7450 ;; Add a context search string
7095 (when (org-xor org-context-in-file-links arg) 7451 (when (org-xor org-context-in-file-links arg)
7452 ;; Check if we are on a target
7096 (if (save-excursion 7453 (if (save-excursion
7097 (skip-chars-backward "a-zA-Z<") 7454 (skip-chars-forward "^>\n\r")
7098 (looking-at (concat "<<\\(" org-camel-regexp "\\)>>"))) 7455 (and (re-search-backward "<<" nil t)
7456 (looking-at "<<\\(.*?\\)>>")
7457 (<= (match-beginning 0) pos)
7458 (>= (match-end 0) pos)))
7099 (setq cpltxt (concat cpltxt "::" (match-string 1))) 7459 (setq cpltxt (concat cpltxt "::" (match-string 1)))
7460 (setq txt (cond
7461 ((org-on-heading-p) nil)
7462 ((org-region-active-p)
7463 (buffer-substring (region-beginning) (region-end)))
7464 (t (buffer-substring (point-at-bol) (point-at-eol)))))
7100 (setq cpltxt 7465 (setq cpltxt
7101 (concat cpltxt "::" 7466 (concat cpltxt "::"
7102 (org-make-org-heading-camel 7467 (if org-file-link-context-use-camel-case
7103 (cond 7468 (org-make-org-heading-camel txt)
7104 ((org-on-heading-p) nil) 7469 (org-make-org-heading-search-string txt))))))
7105 ((org-region-active-p) 7470 (if (string-match "::\\'" cpltxt)
7106 (buffer-substring (region-beginning) (region-end))) 7471 (setq cpltxt (substring cpltxt 0 -2)))
7107 (t (buffer-substring (point-at-bol) (point-at-eol))))
7108 )))))
7109 (setq link (org-make-link cpltxt))) 7472 (setq link (org-make-link cpltxt)))
7110 7473
7111 ((buffer-file-name) 7474 ((buffer-file-name)
@@ -7114,19 +7477,21 @@ For file links, arg negates `org-context-in-file-links'."
7114 (abbreviate-file-name (buffer-file-name)))) 7477 (abbreviate-file-name (buffer-file-name))))
7115 ;; Add a context string 7478 ;; Add a context string
7116 (when (org-xor org-context-in-file-links arg) 7479 (when (org-xor org-context-in-file-links arg)
7480 (setq txt (if (org-region-active-p)
7481 (buffer-substring (region-beginning) (region-end))
7482 (buffer-substring (point-at-bol) (point-at-eol))))
7117 (setq cpltxt 7483 (setq cpltxt
7118 (concat cpltxt "::" 7484 (concat cpltxt "::"
7119 (org-make-org-heading-camel 7485 (if org-file-link-context-use-camel-case
7120 (if (org-region-active-p) 7486 (org-make-org-heading-camel txt)
7121 (buffer-substring (region-beginning) (region-end)) 7487 (org-make-org-heading-search-string txt)))))
7122 (buffer-substring (point-at-bol) (point-at-eol)))))))
7123 (setq link (org-make-link cpltxt))) 7488 (setq link (org-make-link cpltxt)))
7124 7489
7125 ((interactive-p) 7490 ((interactive-p)
7126 (error "Cannot link to a buffer which is not visiting a file")) 7491 (error "Cannot link to a buffer which is not visiting a file"))
7127 7492
7128 (t (setq link nil))) 7493 (t (setq link nil)))
7129 7494
7130 (if (and (interactive-p) link) 7495 (if (and (interactive-p) link)
7131 (progn 7496 (progn
7132 (setq org-stored-links 7497 (setq org-stored-links
@@ -7134,14 +7499,37 @@ For file links, arg negates `org-context-in-file-links'."
7134 (message "Stored: %s" (or cpltxt link))) 7499 (message "Stored: %s" (or cpltxt link)))
7135 link))) 7500 link)))
7136 7501
7137(defun org-make-org-heading-camel (&optional string) 7502(defun org-make-org-heading-search-string (&optional string heading)
7503 "Make search string for S or current headline."
7504 (interactive)
7505 (let ((s (or string (org-get-heading))))
7506 (unless (and string (not heading))
7507 ;; We are using a headline, clean up garbage in there.
7508 (if (string-match org-todo-regexp s)
7509 (setq s (replace-match "" t t s)))
7510 (if (string-match ":[a-zA-Z_@0-9:]+:[ \t]*$" s)
7511 (setq s (replace-match "" t t s)))
7512 (setq s (org-trim s))
7513 (if (string-match (concat "^\\(" org-quote-string "\\|"
7514 org-comment-string "\\)") s)
7515 (setq s (replace-match "" t t s)))
7516 (while (string-match org-ts-regexp s)
7517 (setq s (replace-match "" t t s))))
7518 (while (string-match "[^a-zA-Z_0-9 \t]+" s)
7519 (setq s (replace-match " " t t s)))
7520 (or string (setq s (concat "*" s))) ; Add * for headlines
7521 (mapconcat 'identity (org-split-string s "[ \t]+") " ")))
7522
7523(defun org-make-org-heading-camel (&optional string heading)
7138 "Make a CamelCase string for S or the current headline." 7524 "Make a CamelCase string for S or the current headline."
7139 (interactive) 7525 (interactive)
7140 (let ((s (or string (org-get-heading)))) 7526 (let ((s (or string (org-get-heading))))
7141 (unless string 7527 (unless (and string (not heading))
7142 ;; We are using a headline, clean up garbage in there. 7528 ;; We are using a headline, clean up garbage in there.
7143 (if (string-match org-todo-regexp s) 7529 (if (string-match org-todo-regexp s)
7144 (setq s (replace-match "" t t s))) 7530 (setq s (replace-match "" t t s)))
7531 (if (string-match ":[a-zA-Z_@0-9:]+:[ \t]*$" s)
7532 (setq s (replace-match "" t t s)))
7145 (setq s (org-trim s)) 7533 (setq s (org-trim s))
7146 (if (string-match (concat "^\\(" org-quote-string "\\|" 7534 (if (string-match (concat "^\\(" org-quote-string "\\|"
7147 org-comment-string "\\)") s) 7535 org-comment-string "\\)") s)
@@ -7157,6 +7545,12 @@ For file links, arg negates `org-context-in-file-links'."
7157 "Concatenate STRINGS, format resulting string with `org-link-format'." 7545 "Concatenate STRINGS, format resulting string with `org-link-format'."
7158 (format org-link-format (apply 'concat strings))) 7546 (format org-link-format (apply 'concat strings)))
7159 7547
7548(defun org-make-link2 (link &optional description)
7549 "Make a link with brackets."
7550 (concat "[[" link "]"
7551 (if description (concat "[" description "]") "")
7552 "]"))
7553
7160(defun org-xor (a b) 7554(defun org-xor (a b)
7161 "Exclusive or." 7555 "Exclusive or."
7162 (if a (not b) b)) 7556 (if a (not b) b))
@@ -7245,15 +7639,18 @@ is in the current directory or below."
7245 (let* ((path (match-string 1 link)) 7639 (let* ((path (match-string 1 link))
7246 (case-fold-search nil) 7640 (case-fold-search nil)
7247 (search (match-string 2 link))) 7641 (search (match-string 2 link)))
7248 (when (save-match-data 7642 (when (save-match-data
7249 (equal (file-truename (buffer-file-name)) 7643 (equal (file-truename (buffer-file-name))
7250 (file-truename path))) 7644 (file-truename path)))
7251 (if (save-match-data 7645 ;; We are linking to this same file
7252 (string-match (concat "^" org-camel-regexp "$") search)) 7646 (if (and org-file-link-context-use-camel-case
7253 (setq link (replace-match search t t link) 7647 (save-match-data
7254 matched t) 7648 (string-match (concat "^" org-camel-regexp "$") search)))
7255 (setq link (replace-match (concat "<file:::" search ">") 7649 (setq link (replace-match search t t link)
7256 t t link)))))) 7650 matched t)
7651 (setq link (replace-match (concat "[[" search "]]")
7652 t t link)
7653 matched t)))))
7257 (let ((lines (org-split-string link "\n"))) 7654 (let ((lines (org-split-string link "\n")))
7258 (insert (car lines)) 7655 (insert (car lines))
7259 (setq matched (or matched (string-match org-link-regexp (car lines)))) 7656 (setq matched (or matched (string-match org-link-regexp (car lines))))
@@ -9467,9 +9864,8 @@ table editor in arbitrary modes.")
9467 (and c (setq minor-mode-map-alist 9864 (and c (setq minor-mode-map-alist
9468 (cons c (delq c minor-mode-map-alist))))) 9865 (cons c (delq c minor-mode-map-alist)))))
9469 (set (make-local-variable (quote org-table-may-need-update)) t) 9866 (set (make-local-variable (quote org-table-may-need-update)) t)
9470 (make-local-hook (quote before-change-functions)) ; needed for XEmacs 9867 (org-add-hook 'before-change-functions 'org-before-change-function
9471 (add-hook 'before-change-functions 'org-before-change-function 9868 nil 'local)
9472 nil 'local)
9473 (set (make-local-variable 'org-old-auto-fill-inhibit-regexp) 9869 (set (make-local-variable 'org-old-auto-fill-inhibit-regexp)
9474 auto-fill-inhibit-regexp) 9870 auto-fill-inhibit-regexp)
9475 (set (make-local-variable 'auto-fill-inhibit-regexp) 9871 (set (make-local-variable 'auto-fill-inhibit-regexp)
@@ -9734,6 +10130,10 @@ a reduced column width."
9734 ((string-match "^#" line) 10130 ((string-match "^#" line)
9735 ;; an ordinary comment line 10131 ;; an ordinary comment line
9736 ) 10132 )
10133 ((and org-export-table-remove-special-lines
10134 (string-match "^[ \t]*| *[!_^] *|" line))
10135 ;; a special table line that should be removed
10136 )
9737 (t (setq rtn (cons line rtn))))) 10137 (t (setq rtn (cons line rtn)))))
9738 (nreverse rtn))) 10138 (nreverse rtn)))
9739 10139
@@ -10587,7 +10987,7 @@ headlines. The default is 3. Lower levels will become bulleted lists."
10587 (concat "<a href=\"" thefile "\">\\1:\\2</a>")) 10987 (concat "<a href=\"" thefile "\">\\1:\\2</a>"))
10588 nil nil line)))) 10988 nil nil line))))
10589 10989
10590 ((member type '("bbdb" "vm" "wl" "rmail" "gnus" "shell")) 10990 ((member type '("bbdb" "vm" "wl" "mhe" "rmail" "gnus" "shell"))
10591 (setq line (replace-match 10991 (setq line (replace-match
10592 "<i>&lt;\\1:\\2&gt;</i>" nil nil line))))) 10992 "<i>&lt;\\1:\\2&gt;</i>" nil nil line)))))
10593 10993
@@ -10727,6 +11127,29 @@ headlines. The default is 3. Lower levels will become bulleted lists."
10727 (setq lines (nreverse lines)) 11127 (setq lines (nreverse lines))
10728 (if (string-match "^[ \t]*|-" (car lines)) (setq lines (cdr lines))) 11128 (if (string-match "^[ \t]*|-" (car lines)) (setq lines (cdr lines)))
10729 (setq lines (nreverse lines)) 11129 (setq lines (nreverse lines))
11130 (when org-export-table-remove-special-lines
11131 ;; Check if the table has a marking column. If yes remove the
11132 ;; column and the special lines
11133 (let* ((special
11134 (not
11135 (memq nil
11136 (mapcar
11137 (lambda (x)
11138 (or (string-match "^[ \t]*|-" x)
11139 (string-match "^[ \t]*| *\\([#!$*_^ ]\\) *|" x)))
11140 lines)))))
11141 (if special
11142 (setq lines
11143 (delq nil
11144 (mapcar
11145 (lambda (x)
11146 (if (string-match "^[ \t]*| *[!_^] *|" x)
11147 nil ; ignore this line
11148 (and (or (string-match "^[ \t]*|-+\\+" x)
11149 (string-match "^[ \t]*|[^|]*|" x))
11150 (replace-match "|" t t x))))
11151 lines))))))
11152
10730 (let ((head (and org-export-highlight-first-table-line 11153 (let ((head (and org-export-highlight-first-table-line
10731 (delq nil (mapcar 11154 (delq nil (mapcar
10732 (lambda (x) (string-match "^[ \t]*|-" x)) 11155 (lambda (x) (string-match "^[ \t]*|-" x))
@@ -11210,10 +11633,10 @@ a time), or the day by one (if it does not contain a time)."
11210 11633
11211;; - Bindings in Org-mode map are currently 11634;; - Bindings in Org-mode map are currently
11212;; 0123456789abcdefghijklmnopqrstuvwxyz!?@#$%^&-+*/=()_{}[]:;"|,.<>~`'\t the alphabet 11635;; 0123456789abcdefghijklmnopqrstuvwxyz!?@#$%^&-+*/=()_{}[]:;"|,.<>~`'\t the alphabet
11213;; abcd fgh j lmnopqrstuvwxyz!? #$ -+*/= [] ; |,.<>~ \t necessary bindings 11636;; abcd fgh j lmnopqrstuvwxyz!? #$ ^ -+*/= [] ; |,.<>~ '\t necessary bindings
11214;; e (?) useful from outline-mode 11637;; e (?) useful from outline-mode
11215;; i k @ expendable from outline-mode 11638;; i k @ expendable from outline-mode
11216;; 0123456789 %^& ()_{} " `' free 11639;; 0123456789 % & ()_{} " ` free
11217 11640
11218;; Make `C-c C-x' a prefix key 11641;; Make `C-c C-x' a prefix key
11219(define-key org-mode-map "\C-c\C-x" (make-sparse-keymap)) 11642(define-key org-mode-map "\C-c\C-x" (make-sparse-keymap))
@@ -11281,6 +11704,8 @@ a time), or the day by one (if it does not contain a time)."
11281(define-key org-mode-map "\M-\C-m" 'org-insert-heading) 11704(define-key org-mode-map "\M-\C-m" 'org-insert-heading)
11282(define-key org-mode-map "\C-c\C-l" 'org-insert-link) 11705(define-key org-mode-map "\C-c\C-l" 'org-insert-link)
11283(define-key org-mode-map "\C-c\C-o" 'org-open-at-point) 11706(define-key org-mode-map "\C-c\C-o" 'org-open-at-point)
11707(define-key org-mode-map "\C-c%" 'org-mark-ring-push)
11708(define-key org-mode-map "\C-c&" 'org-mark-ring-goto)
11284(define-key org-mode-map "\C-c\C-z" 'org-time-stamp) ; Alternative binding 11709(define-key org-mode-map "\C-c\C-z" 'org-time-stamp) ; Alternative binding
11285(define-key org-mode-map "\C-c." 'org-time-stamp) ; Minor-mode reserved 11710(define-key org-mode-map "\C-c." 'org-time-stamp) ; Minor-mode reserved
11286(define-key org-mode-map "\C-c!" 'org-time-stamp-inactive) ; Minor-mode r. 11711(define-key org-mode-map "\C-c!" 'org-time-stamp-inactive) ; Minor-mode r.
@@ -11594,6 +12019,7 @@ If the cursor is on a #+TBLFM line, re-apply the formulae to the table."
11594 (interactive "P") 12019 (interactive "P")
11595 (let ((org-enable-table-editor t)) 12020 (let ((org-enable-table-editor t))
11596 (cond 12021 (cond
12022 ((org-on-target-p) (org-update-radio-target-regexp))
11597 ((org-on-heading-p) (org-set-tags arg)) 12023 ((org-on-heading-p) (org-set-tags arg))
11598 ((org-at-table.el-p) 12024 ((org-at-table.el-p)
11599 (require 'table) 12025 (require 'table)
@@ -11935,6 +12361,11 @@ work correctly."
11935 12361
11936;; Functions needed for Emacs/XEmacs region compatibility 12362;; Functions needed for Emacs/XEmacs region compatibility
11937 12363
12364(defun org-add-hook (hook function &optional append local)
12365 "Add-hook, compatible with both Emacsen."
12366 (if (and local org-xemacs-p) (make-local-hook hook)) ;; Needed for XEmacs
12367 (add-hook hook function append local))
12368
11938(defun org-region-active-p () 12369(defun org-region-active-p ()
11939 "Is `transient-mark-mode' on and the region active? 12370 "Is `transient-mark-mode' on and the region active?
11940Works on both Emacs and XEmacs." 12371Works on both Emacs and XEmacs."
@@ -12030,6 +12461,19 @@ to a visible line beginning. This makes the function of C-a more intuitive."
12030 (skip-chars-backward "^\r\n") 12461 (skip-chars-backward "^\r\n")
12031 (equal (char-before) ?\r)))) 12462 (equal (char-before) ?\r))))
12032 12463
12464(defun org-invisible-p2 ()
12465 "Check if point is at a character currently not visible."
12466 (save-excursion
12467 (if org-noutline-p
12468 (progn
12469 (if (and (eolp) (not (bobp))) (backward-char 1))
12470 ;; Early versions of noutline don't have `outline-invisible-p'.
12471 (if (fboundp 'outline-invisible-p)
12472 (outline-invisible-p)
12473 (get-char-property (point) 'invisible)))
12474 (skip-chars-backward "^\r\n")
12475 (equal (char-before) ?\r))))
12476
12033(defun org-back-to-heading (&optional invisible-ok) 12477(defun org-back-to-heading (&optional invisible-ok)
12034 "Move to previous heading line, or beg of this line if it's a heading. 12478 "Move to previous heading line, or beg of this line if it's a heading.
12035Only visible heading lines are considered, unless INVISIBLE-OK is non-nil." 12479Only visible heading lines are considered, unless INVISIBLE-OK is non-nil."
@@ -12058,6 +12502,16 @@ If INVISIBLE-OK is non-nil, an invisible heading line is ok too."
12058 (bobp) 12502 (bobp)
12059 (equal (char-before) ?\n)))))) 12503 (equal (char-before) ?\n))))))
12060 12504
12505(defun org-on-target-p ()
12506 (let ((pos (point)))
12507 (save-excursion
12508 (skip-chars-forward "<")
12509 (and (re-search-backward "<<" nil t)
12510 (or (looking-at org-target-regexp)
12511 (looking-at org-radio-target-regexp))
12512 (<= (match-beginning 0) pos)
12513 (>= (match-end 0) pos)))))
12514
12061(defun org-up-heading-all (arg) 12515(defun org-up-heading-all (arg)
12062 "Move to the heading line of which the present line is a subheading. 12516 "Move to the heading line of which the present line is a subheading.
12063This function considers both visible and invisible heading lines. 12517This function considers both visible and invisible heading lines.
@@ -12195,4 +12649,3 @@ Show the heading too, if it is currently invisible."
12195;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd 12649;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd
12196;;; org.el ends here 12650;;; org.el ends here
12197 12651
12198