comparison lisp/textmodes/org.el @ 70010:c49248393916

(org-set-regexps-and-options, org-get-current-options): Better names for the startup folding options.
author Carsten Dominik <dominik@science.uva.nl>
date Thu, 13 Apr 2006 13:48:37 +0000
parents d39b38d0fe6f
children 8676ce0ffe86
comparison
equal deleted inserted replaced
70009:d39b38d0fe6f 70010:c49248393916
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.22 8 ;; Version: 4.23
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.23
85 ;; - Bug fixes.
86 ;;
84 ;; Version 4.22 87 ;; Version 4.22
85 ;; - Bug fixes. 88 ;; - Bug fixes.
86 ;; - In agenda buffer, mouse-1 no longer follows link. 89 ;; - In agenda buffer, mouse-1 no longer follows link.
87 ;; See `org-agenda-mouse-1-follows-link' and `org-mouse-1-follows-link'. 90 ;; See `org-agenda-mouse-1-follows-link' and `org-mouse-1-follows-link'.
88 ;; 91 ;;
2179 (setq int 'type 2182 (setq int 'type
2180 kwds (append kwds (org-split-string value splitre)))) 2183 kwds (append kwds (org-split-string value splitre))))
2181 ((equal key "STARTUP") 2184 ((equal key "STARTUP")
2182 (let ((opts (org-split-string value splitre)) 2185 (let ((opts (org-split-string value splitre))
2183 (set '(("fold" org-startup-folded t) 2186 (set '(("fold" org-startup-folded t)
2187 ("overview" org-startup-folded t)
2184 ("nofold" org-startup-folded nil) 2188 ("nofold" org-startup-folded nil)
2189 ("showall" org-startup-folded nil)
2185 ("content" org-startup-folded content) 2190 ("content" org-startup-folded content)
2186 ("hidestars" org-hide-leading-stars t) 2191 ("hidestars" org-hide-leading-stars t)
2187 ("showstars" org-hide-leading-stars nil) 2192 ("showstars" org-hide-leading-stars nil)
2188 ("odd" org-odd-levels-only t) 2193 ("odd" org-odd-levels-only t)
2189 ("oddeven" org-odd-levels-only nil) 2194 ("oddeven" org-odd-levels-only nil)
7687 (mh-search "+" article)) 7692 (mh-search "+" article))
7688 (if (org-mhe-get-message-real-folder) 7693 (if (org-mhe-get-message-real-folder)
7689 (mh-show-msg 1) 7694 (mh-show-msg 1)
7690 (kill-this-buffer) 7695 (kill-this-buffer)
7691 (error "Message not found")))) 7696 (error "Message not found"))))
7697
7698 (defun org-upgrade-old-links (&optional query-description)
7699 "Transfer old <...> style links to new [[...]] style links.
7700 With arg query-description, ask at each match for a description text to use
7701 for this link."
7702 (interactive (list (y-or-n-p "Would you like to be queried for a description at each link?")))
7703 (save-excursion
7704 (goto-char (point-min))
7705 (let ((re (concat "\\([^[]\\)<\\("
7706 "\\(" (mapconcat 'identity org-link-types "\\|")
7707 "\\):"
7708 "[^" org-non-link-chars "]+\\)>"))
7709 l1 l2 (cnt 0))
7710 (while (re-search-forward re nil t)
7711 (setq cnt (1+ cnt)
7712 l1 (org-match-string-no-properties 2)
7713 l2 (save-match-data (org-link-escape l1)))
7714 (when query-description (setq l1 (read-string "Desc: " l1)))
7715 (if (equal l1 l2)
7716 (replace-match (concat (match-string 1) "[[" l1 "]]") t t)
7717 (replace-match (concat (match-string 1) "[[" l2 "][" l1 "]]") t t)))
7718 (message "%d matches have beed treated" cnt))))
7692 7719
7693 (defun org-open-file (path &optional in-emacs line search) 7720 (defun org-open-file (path &optional in-emacs line search)
7694 "Open the file at PATH. 7721 "Open the file at PATH.
7695 First, this expands any special file name abbreviations. Then the 7722 First, this expands any special file name abbreviations. Then the
7696 configuration variable `org-file-apps' is checked if it contains an 7723 configuration variable `org-file-apps' is checked if it contains an
11395 "TODO FEEDBACK VERIFY DONE") 11422 "TODO FEEDBACK VERIFY DONE")
11396 (if (equal org-todo-interpretation 'type) 11423 (if (equal org-todo-interpretation 'type)
11397 (mapconcat 'identity org-todo-keywords " ") 11424 (mapconcat 'identity org-todo-keywords " ")
11398 "Me Jason Marie DONE") 11425 "Me Jason Marie DONE")
11399 (cdr (assoc org-startup-folded 11426 (cdr (assoc org-startup-folded
11400 '((nil . "nofold")(t . "fold")(content . "content")))) 11427 '((nil . "showall") (t . "overview") (content . "content"))))
11401 (if org-startup-with-deadline-check "dlcheck" "nodlcheck") 11428 (if org-startup-with-deadline-check "dlcheck" "nodlcheck")
11402 (if org-odd-levels-only "odd" "oddeven") 11429 (if org-odd-levels-only "odd" "oddeven")
11403 (if org-hide-leading-stars "hidestars" "showstars") 11430 (if org-hide-leading-stars "hidestars" "showstars")
11404 (if org-startup-align-all-tables "align" "noalign") 11431 (if org-startup-align-all-tables "align" "noalign")
11405 org-archive-location 11432 org-archive-location
12215 The iCalendar file will be located in the same directory as the Org-mode 12242 The iCalendar file will be located in the same directory as the Org-mode
12216 file, but with extension `.ics'." 12243 file, but with extension `.ics'."
12217 (interactive) 12244 (interactive)
12218 (org-export-icalendar nil buffer-file-name)) 12245 (org-export-icalendar nil buffer-file-name))
12219 12246
12247 (defun org-export-as-xml ()
12248 "Export current buffer as XOXO XML buffer."
12249 (interactive)
12250 (cond ((eq org-export-xml-type 'xoxo)
12251 (org-export-as-xoxo (current-buffer)))))
12252
12253 (defun org-export-as-xoxo-insert-into (buffer &rest output)
12254 (with-current-buffer buffer
12255 (apply 'insert output)))
12256
12257 (defun org-export-as-xoxo (&optional buffer)
12258 "Export the org buffer as XOXO.
12259 The XOXO buffer is named *xoxo-<source buffer name>*"
12260 (interactive (list (current-buffer)))
12261 ;; A quickie abstraction
12262
12263 ;; Output everything as XOXO
12264 (with-current-buffer (get-buffer buffer)
12265 (goto-char (point-min)) ;; CD: beginning-of-buffer is not allowed.
12266 (let* ((filename (concat (file-name-sans-extension buffer-file-name)
12267 ".xml"))
12268 (out (find-file-noselect filename))
12269 (last-level 1)
12270 (hanging-li nil))
12271 ;; Check the output buffer is empty.
12272 (with-current-buffer out (erase-buffer))
12273 ;; Kick off the output
12274 (org-export-as-xoxo-insert-into out "<ol class='xoxo'>\n")
12275 (while (re-search-forward "^\\(\\*+\\) \\(.+\\)" (point-max) 't)
12276 (let* ((hd (match-string-no-properties 1))
12277 (level (length hd))
12278 (text (concat
12279 (match-string-no-properties 2)
12280 (save-excursion
12281 (goto-char (match-end 0))
12282 (let ((str ""))
12283 (catch 'loop
12284 (while 't
12285 (forward-line)
12286 (if (looking-at "^[ \t]\\(.*\\)")
12287 (setq str (concat str (match-string-no-properties 1)))
12288 (throw 'loop str)))))))))
12289
12290 ;; Handle level rendering
12291 (cond
12292 ((> level last-level)
12293 (org-export-as-xoxo-insert-into out "\n<ol>\n"))
12294
12295 ((< level last-level)
12296 (dotimes (- (- last-level level) 1)
12297 (if hanging-li
12298 (org-export-as-xoxo-insert-into out "</li>\n"))
12299 (org-export-as-xoxo-insert-into out "</ol>\n"))
12300 (when hanging-li
12301 (org-export-as-xoxo-insert-into out "</li>\n")
12302 (setq hanging-li nil)))
12303
12304 ((equal level last-level)
12305 (if hanging-li
12306 (org-export-as-xoxo-insert-into out "</li>\n")))
12307 )
12308
12309 (setq last-level level)
12310
12311 ;; And output the new li
12312 (setq hanging-li 't)
12313 (if (equal ?+ (elt text 0))
12314 (org-export-as-xoxo-insert-into out "<li class='" (substring text 1) "'>")
12315 (org-export-as-xoxo-insert-into out "<li>" text))))
12316
12317 ;; Finally finish off the ol
12318 (dotimes (- last-level 1)
12319 (if hanging-li
12320 (org-export-as-xoxo-insert-into out "</li>\n"))
12321 (org-export-as-xoxo-insert-into out "</ol>\n"))
12322
12323 ;; Finish the buffer off and clean it up.
12324 (switch-to-buffer-other-window out)
12325 (indent-region (point-min) (point-max))
12326 (save-buffer)
12327 (goto-char (point-min))
12328 )))
12329
12220 ;;;###autoload 12330 ;;;###autoload
12221 (defun org-export-icalendar-all-agenda-files () 12331 (defun org-export-icalendar-all-agenda-files ()
12222 "Export all files in `org-agenda-files' to iCalendar .ics files. 12332 "Export all files in `org-agenda-files' to iCalendar .ics files.
12223 Each iCalendar file will be located in the same directory as the Org-mode 12333 Each iCalendar file will be located in the same directory as the Org-mode
12224 file, but with extension `.ics'." 12334 file, but with extension `.ics'."
12780 12890
12781 - If the cursor is on a #+TBLFM line, re-apply the formulas to 12891 - If the cursor is on a #+TBLFM line, re-apply the formulas to
12782 the entire table. 12892 the entire table.
12783 12893
12784 - If the cursor is inside a table created by the table.el package, 12894 - If the cursor is inside a table created by the table.el package,
12785 activate that table. Otherwise, if the cursor is at a normal table 12895 activate that table.
12786 created with org.el, re-align that table.
12787 12896
12788 - If the current buffer is a remember buffer, close note and file it. 12897 - If the current buffer is a remember buffer, close note and file it.
12789 with a prefix argument, file it without further interaction to the default 12898 with a prefix argument, file it without further interaction to the default
12790 location. 12899 location.
12791 12900
13405 (save-excursion 13514 (save-excursion
13406 (re-search-forward (concat "[\r\n]\\(" outline-regexp "\\)") nil 'move) 13515 (re-search-forward (concat "[\r\n]\\(" outline-regexp "\\)") nil 'move)
13407 (or (match-beginning 1) (point-max))) 13516 (or (match-beginning 1) (point-max)))
13408 (if org-noutline-p nil ?\n)))) 13517 (if org-noutline-p nil ?\n))))
13409 13518
13410
13411 (defun org-make-options-regexp (kwds) 13519 (defun org-make-options-regexp (kwds)
13412 "Make a regular expression for keyword lines." 13520 "Make a regular expression for keyword lines."
13413 (concat 13521 (concat
13414 (if org-noutline-p "^" "[\n\r]") 13522 (if org-noutline-p "^" "[\n\r]")
13415 "#?[ \t]*\\+\\(" 13523 "#?[ \t]*\\+\\("
13439 13547
13440 (provide 'org) 13548 (provide 'org)
13441 13549
13442 (run-hooks 'org-load-hook) 13550 (run-hooks 'org-load-hook)
13443 13551
13444 ;; Experimental code
13445 ;; FIXME: Move this code when it is ready.
13446
13447 (defun org-upgrade-old-links (&optional query-description)
13448 "Transfer old <...> style links to new [[...]] style links.
13449 With arg query-description, ask at each match for a description text to use
13450 for this link."
13451 (interactive (list (y-or-n-p "Would you like to be queried for a description at each link?")))
13452 (save-excursion
13453 (goto-char (point-min))
13454 (let ((re (concat "\\([^[]\\)<\\("
13455 "\\(" (mapconcat 'identity org-link-types "\\|")
13456 "\\):"
13457 "[^" org-non-link-chars "]+\\)>"))
13458 l1 l2 (cnt 0))
13459 (while (re-search-forward re nil t)
13460 (setq cnt (1+ cnt)
13461 l1 (org-match-string-no-properties 2)
13462 l2 (save-match-data (org-link-escape l1)))
13463 (when query-description (setq l1 (read-string "Desc: " l1)))
13464 (if (equal l1 l2)
13465 (replace-match (concat (match-string 1) "[[" l1 "]]") t t)
13466 (replace-match (concat (match-string 1) "[[" l2 "][" l1 "]]") t t)))
13467 (message "%d matches have beed treated" cnt))))
13468
13469 (defun org-export-as-xml ()
13470 "Export current buffer as XOXO XML buffer."
13471 (interactive)
13472 (cond ((eq org-export-xml-type 'xoxo)
13473 (org-export-as-xoxo (current-buffer)))))
13474
13475 (defun org-export-as-xoxo-insert-into (buffer &rest output)
13476 (with-current-buffer buffer
13477 (apply 'insert output)))
13478
13479 (defun org-export-as-xoxo (&optional buffer)
13480 "Export the org buffer as XOXO.
13481 The XOXO buffer is named *xoxo-<source buffer name>*"
13482 (interactive (list (current-buffer)))
13483 ;; A quickie abstraction
13484
13485 ;; Output everything as XOXO
13486 (with-current-buffer (get-buffer buffer)
13487 (goto-char (point-min)) ;; CD: beginning-of-buffer is not allowed.
13488 (let* ((filename (concat (file-name-sans-extension buffer-file-name)
13489 ".xml"))
13490 (out (find-file-noselect filename))
13491 (last-level 1)
13492 (hanging-li nil))
13493 ;; Check the output buffer is empty.
13494 (with-current-buffer out (erase-buffer))
13495 ;; Kick off the output
13496 (org-export-as-xoxo-insert-into out "<ol class='xoxo'>\n")
13497 (while (re-search-forward "^\\(\\*+\\) \\(.+\\)" (point-max) 't)
13498 (let* ((hd (match-string-no-properties 1))
13499 (level (length hd))
13500 (text (concat
13501 (match-string-no-properties 2)
13502 (save-excursion
13503 (goto-char (match-end 0))
13504 (let ((str ""))
13505 (catch 'loop
13506 (while 't
13507 (forward-line)
13508 (if (looking-at "^[ \t]\\(.*\\)")
13509 (setq str (concat str (match-string-no-properties 1)))
13510 (throw 'loop str)))))))))
13511
13512 ;; Handle level rendering
13513 (cond
13514 ((> level last-level)
13515 (org-export-as-xoxo-insert-into out "\n<ol>\n"))
13516
13517 ((< level last-level)
13518 (dotimes (- (- last-level level) 1)
13519 (if hanging-li
13520 (org-export-as-xoxo-insert-into out "</li>\n"))
13521 (org-export-as-xoxo-insert-into out "</ol>\n"))
13522 (when hanging-li
13523 (org-export-as-xoxo-insert-into out "</li>\n")
13524 (setq hanging-li nil)))
13525
13526 ((equal level last-level)
13527 (if hanging-li
13528 (org-export-as-xoxo-insert-into out "</li>\n")))
13529 )
13530
13531 (setq last-level level)
13532
13533 ;; And output the new li
13534 (setq hanging-li 't)
13535 (if (equal ?+ (elt text 0))
13536 (org-export-as-xoxo-insert-into out "<li class='" (substring text 1) "'>")
13537 (org-export-as-xoxo-insert-into out "<li>" text))))
13538
13539 ;; Finally finish off the ol
13540 (dotimes (- last-level 1)
13541 (if hanging-li
13542 (org-export-as-xoxo-insert-into out "</li>\n"))
13543 (org-export-as-xoxo-insert-into out "</ol>\n"))
13544
13545 ;; Finish the buffer off and clean it up.
13546 (switch-to-buffer-other-window out)
13547 (indent-region (point-min) (point-max))
13548 (save-buffer)
13549 (goto-char (point-min))
13550 )))
13551
13552 ;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd 13552 ;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd
13553 ;;; org.el ends here 13553 ;;; org.el ends here
13554