aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Dominik2005-12-08 13:08:54 +0000
committerCarsten Dominik2005-12-08 13:08:54 +0000
commitb2de034e143dd6d78533c02748ab22b576ca86e3 (patch)
tree0e06f71c13ab851956ec53c2b5039004ba938cef
parent3f30c2726a7a438c9a9d850f87f8f8e82599d353 (diff)
downloademacs-b2de034e143dd6d78533c02748ab22b576ca86e3.tar.gz
emacs-b2de034e143dd6d78533c02748ab22b576ca86e3.zip
(org-insert-heading): Try to do items before headings.
(org-agenda-mode): Quote `org-agenda-mode-hook'. (org-insert-item): New function. (org-renumber-ordered-list): Don't skip to higher level lists.
-rw-r--r--lisp/textmodes/org.el77
1 files changed, 51 insertions, 26 deletions
diff --git a/lisp/textmodes/org.el b/lisp/textmodes/org.el
index 6d2db55654d..47d6464da19 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 6;; Keywords: outlines, hypermedia, calendar
7;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/ 7;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/
8;; Version: 3.22 8;; Version: 3.23
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
@@ -82,6 +82,10 @@
82;; 82;;
83;; Changes: 83;; Changes:
84;; ------- 84;; -------
85;; Version 3.23
86;; - M-RET makes new items as well as new headings.
87;; - Various small bug fixes
88;;
85;; Version 3.22 89;; Version 3.22
86;; - CamelCase words link to other locations in the same file. 90;; - CamelCase words link to other locations in the same file.
87;; - File links accept search options, to link to specific locations. 91;; - File links accept search options, to link to specific locations.
@@ -253,7 +257,7 @@
253 257
254;;; Customization variables 258;;; Customization variables
255 259
256(defvar org-version "3.22" 260(defvar org-version "3.23"
257 "The version number of the file org.el.") 261 "The version number of the file org.el.")
258(defun org-version () 262(defun org-version ()
259 (interactive) 263 (interactive)
@@ -2530,22 +2534,39 @@ or nil."
2530(defvar org-ignore-region nil 2534(defvar org-ignore-region nil
2531 "To temporarily disable the active region.") 2535 "To temporarily disable the active region.")
2532 2536
2533(defun org-insert-heading () 2537(defun org-insert-heading (&optional force-heading)
2534 "Insert a new heading with same depth at point." 2538 "Insert a new heading or item with same depth at point.
2535 (interactive) 2539If ARG is non-nil"
2536 (let* ((head (save-excursion 2540 (interactive "P")
2537 (condition-case nil 2541 (when (or force-heading (not (org-insert-item)))
2538 (org-back-to-heading) 2542 (let* ((head (save-excursion
2539 (error (outline-next-heading))) 2543 (condition-case nil
2540 (prog1 (match-string 0) 2544 (org-back-to-heading)
2541 (funcall outline-level))))) 2545 (error (outline-next-heading)))
2546 (prog1 (match-string 0)
2547 (funcall outline-level)))))
2548 (unless (bolp) (newline))
2549 (insert head)
2550 (unless (eolp)
2551 (save-excursion (newline-and-indent)))
2552 (unless (equal (char-before) ?\ )
2553 (insert " "))
2554 (run-hooks 'org-insert-heading-hook))))
2555
2556(defun org-insert-item ()
2557 "Insert a new item at the current level.
2558Return t when tings worked, nil when we are not in an item."
2559 (when (save-excursion
2560 (condition-case nil
2561 (progn
2562 (org-beginning-of-item)
2563 (org-at-item-p)
2564 t)
2565 (error nil)))
2542 (unless (bolp) (newline)) 2566 (unless (bolp) (newline))
2543 (insert head) 2567 (insert (match-string 0))
2544 (unless (eolp) 2568 (org-maybe-renumber-ordered-list)
2545 (save-excursion (newline-and-indent))) 2569 t))
2546 (unless (equal (char-before) ?\ )
2547 (insert " "))
2548 (run-hooks 'org-insert-heading-hook)))
2549 2570
2550(defun org-insert-todo-heading (arg) 2571(defun org-insert-todo-heading (arg)
2551 "Insert a new heading with the same level and TODO state as current heading. 2572 "Insert a new heading with the same level and TODO state as current heading.
@@ -3034,8 +3055,9 @@ with something like \"1.\" or \"2)\"."
3034 (beginning-of-line 0) 3055 (beginning-of-line 0)
3035 (if (looking-at "[ \t]*$") (throw 'next t)) 3056 (if (looking-at "[ \t]*$") (throw 'next t))
3036 (skip-chars-forward " \t") (setq ind1 (current-column)) 3057 (skip-chars-forward " \t") (setq ind1 (current-column))
3037 (if (and (<= ind1 ind) 3058 (if (or (< ind1 ind)
3038 (not (org-at-item-p))) 3059 (and (= ind1 ind)
3060 (not (org-at-item-p))))
3039 (throw 'exit t))))) 3061 (throw 'exit t)))))
3040 ;; Walk forward and replace these numbers 3062 ;; Walk forward and replace these numbers
3041 (catch 'exit 3063 (catch 'exit
@@ -3055,7 +3077,7 @@ with something like \"1.\" or \"2)\"."
3055 (insert (format "%d" (setq n (1+ n))))))) 3077 (insert (format "%d" (setq n (1+ n)))))))
3056 (goto-line line) 3078 (goto-line line)
3057 (move-to-column col))) 3079 (move-to-column col)))
3058 3080
3059(defvar org-last-indent-begin-marker (make-marker)) 3081(defvar org-last-indent-begin-marker (make-marker))
3060(defvar org-last-indent-end-marker (make-marker)) 3082(defvar org-last-indent-end-marker (make-marker))
3061 3083
@@ -3422,9 +3444,10 @@ that the match should indeed be shown."
3422 (save-match-data (funcall callback))) 3444 (save-match-data (funcall callback)))
3423 (setq cnt (1+ cnt)) 3445 (setq cnt (1+ cnt))
3424 (org-highlight-new-match (match-beginning 0) (match-end 0)) 3446 (org-highlight-new-match (match-beginning 0) (match-end 0))
3425 (add-hook 'before-change-functions 'org-remove-occur-highlights
3426 nil 'local)
3427 (org-show-hierarchy-above)))) 3447 (org-show-hierarchy-above))))
3448 (make-local-hook 'before-change-functions) ; needed for XEmacs
3449 (add-hook 'before-change-functions 'org-remove-occur-highlights
3450 nil 'local)
3428 (run-hooks 'org-occur-hook) 3451 (run-hooks 'org-occur-hook)
3429 (if (interactive-p) 3452 (if (interactive-p)
3430 (message "%d match(es) for regexp %s" cnt regexp)) 3453 (message "%d match(es) for regexp %s" cnt regexp))
@@ -4036,7 +4059,9 @@ The following commands are available:
4036 (use-local-map org-agenda-mode-map) 4059 (use-local-map org-agenda-mode-map)
4037 (easy-menu-add org-agenda-menu) 4060 (easy-menu-add org-agenda-menu)
4038 (if org-startup-truncated (setq truncate-lines t)) 4061 (if org-startup-truncated (setq truncate-lines t))
4062 (make-local-hook 'post-command-hook) ; Needed for XEmacs
4039 (add-hook 'post-command-hook 'org-agenda-post-command-hook nil 'local) 4063 (add-hook 'post-command-hook 'org-agenda-post-command-hook nil 'local)
4064 (make-local-hook 'pre-command-hook) ; Needed for XEmacs
4040 (add-hook 'pre-command-hook 'org-unhighlight nil 'local) 4065 (add-hook 'pre-command-hook 'org-unhighlight nil 'local)
4041 (setq org-agenda-follow-mode nil) 4066 (setq org-agenda-follow-mode nil)
4042 (easy-menu-change 4067 (easy-menu-change
@@ -4049,7 +4074,7 @@ The following commands are available:
4049 (org-agenda-set-mode-name) 4074 (org-agenda-set-mode-name)
4050 (apply 4075 (apply
4051 (if (fboundp 'run-mode-hooks) 'run-mode-hooks 'run-hooks) 4076 (if (fboundp 'run-mode-hooks) 'run-mode-hooks 'run-hooks)
4052 org-agenda-mode-hook)) 4077 (list 'org-agenda-mode-hook)))
4053 4078
4054(define-key org-agenda-mode-map "\C-i" 'org-agenda-goto) 4079(define-key org-agenda-mode-map "\C-i" 'org-agenda-goto)
4055(define-key org-agenda-mode-map "\C-m" 'org-agenda-switch-to) 4080(define-key org-agenda-mode-map "\C-m" 'org-agenda-switch-to)
@@ -4903,8 +4928,8 @@ function from a program - use `org-agenda-get-day-entries' instead."
4903 (let (tbl) 4928 (let (tbl)
4904 (save-excursion 4929 (save-excursion
4905 (goto-char (point-min)) 4930 (goto-char (point-min))
4906 (while (re-search-forward "^#\\+CATEGORY:[ \t]*\\(.*\\)" nil t) 4931 (while (re-search-forward "\\(^\\|\r\\)#\\+CATEGORY:[ \t]*\\(.*\\)" nil t)
4907 (push (cons (point) (org-trim (match-string 1))) tbl))) 4932 (push (cons (point) (org-trim (match-string 2))) tbl)))
4908 tbl)) 4933 tbl))
4909 (defun org-get-category (&optional pos) 4934 (defun org-get-category (&optional pos)
4910 "Get the category applying to position POS." 4935 "Get the category applying to position POS."
@@ -10899,7 +10924,7 @@ See the individual commands for more information."
10899 (cond 10924 (cond
10900 ((org-at-table-p) 10925 ((org-at-table-p)
10901 (org-table-wrap-region arg)) 10926 (org-table-wrap-region arg))
10902 (t (org-insert-heading)))) 10927 (t (org-insert-heading arg))))
10903 10928
10904;;; Menu entries 10929;;; Menu entries
10905 10930