Continue fixing b508ff69.

* org.el (org-outline-level): Go at the beginning of the
headline first to always return a sensible result.

* org-agenda.el (org-search-view, org-agenda-get-todos)
(org-agenda-get-timestamps, org-agenda-get-sexps)
(org-agenda-get-progress, org-agenda-get-deadlines)
(org-agenda-get-scheduled, org-agenda-get-blocks): Return the
correct level depending on `org-odd-levels-only'.
This commit is contained in:
Bastien Guerry 2012-09-12 18:17:01 +02:00
parent b645e8ab22
commit 9742dc86a0
2 changed files with 14 additions and 12 deletions

View File

@ -4283,7 +4283,7 @@ in `org-agenda-text-search-extra-files'."
(goto-char beg)
(setq marker (org-agenda-new-marker (point))
category (org-get-category)
level (make-string (1- (or (org-outline-level) 1)) ? )
level (make-string (org-reduced-level (org-outline-level)) ? )
category-pos (get-text-property (point) 'org-category-position)
tags (org-get-tags-at (point))
txt (org-agenda-format-item
@ -5010,7 +5010,7 @@ the documentation of `org-diary'."
txt (org-trim
(buffer-substring (match-beginning 2) (match-end 0)))
tags (org-get-tags-at (point))
level (make-string (1- (or (org-outline-level) 1)) ? )
level (make-string (org-reduced-level (org-outline-level)) ? )
txt (org-agenda-format-item "" txt level category tags)
priority (1+ (org-get-priority txt))
todo-state (org-get-todo-state))
@ -5186,7 +5186,7 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
(throw :skip nil))
(setq hdmarker (org-agenda-new-marker)
tags (org-get-tags-at)
level (make-string (1- (or (org-outline-level) 1)) ? ))
level (make-string (org-reduced-level (org-outline-level)) ? ))
(looking-at "\\*+[ \t]+\\([^\r\n]+\\)")
(setq head (or (match-string 1) ""))
(setq txt (org-agenda-format-item
@ -5234,7 +5234,7 @@ This function is invoked if `org-agenda-todo-ignore-deadlines',
(setq result (org-diary-sexp-entry sexp sexp-entry date))
(when result
(setq marker (org-agenda-new-marker beg)
level (make-string (1- (or (org-outline-level) 1)) ? )
level (make-string (org-reduced-level (org-outline-level)) ? )
category (org-get-category beg)
category-pos (get-text-property beg 'org-category-position)
tags (save-excursion (org-backward-heading-same-level 0)
@ -5408,7 +5408,7 @@ please use `org-class' instead."
(goto-char (match-beginning 0))
(setq hdmarker (org-agenda-new-marker)
tags (org-get-tags-at)
level (make-string (1- (or (org-outline-level) 1)) ? ))
level (make-string (org-reduced-level (org-outline-level)) ? ))
(looking-at "\\*+[ \t]+\\([^\r\n]+\\)")
(setq txt (match-string 1))
(when extra
@ -5619,7 +5619,7 @@ See also the user option `org-agenda-clock-consistency-checks'."
(setq txt org-agenda-no-heading-message)
(goto-char (match-end 0))
(setq pos1 (match-beginning 0))
(setq level (make-string (1- (or (org-outline-level) 1)) ? ))
(setq level (make-string (org-reduced-level (org-outline-level)) ? ))
(setq tags (org-get-tags-at pos1))
(setq head (buffer-substring-no-properties
(point)
@ -5750,7 +5750,7 @@ FRACTION is what fraction of the head-warning time has passed."
(setq mm (assoc pos1 deadline-position-alist)))
(throw :skip nil)))
(setq tags (org-get-tags-at))
(setq level (make-string (1- (or (org-outline-level) 1)) ? ))
(setq level (make-string (org-reduced-level (org-outline-level)) ? ))
(setq head (buffer-substring-no-properties
(point)
(progn (skip-chars-forward "^\r\n") (point))))
@ -5834,7 +5834,7 @@ FRACTION is what fraction of the head-warning time has passed."
(goto-char (match-beginning 0))
(setq hdmarker (org-agenda-new-marker (point)))
(setq tags (org-get-tags-at))
(setq level (make-string (1- (or (org-outline-level) 1)) ? ))
(setq level (make-string (org-reduced-level (org-outline-level)) ? ))
(looking-at "\\*+[ \t]+\\([^\r\n]+\\)")
(setq head (match-string 1))
(let ((remove-re

View File

@ -5878,13 +5878,15 @@ between words."
(defun org-outline-level ()
"Compute the outline level of the heading at point.
This function assumes that the cursor is at the beginning of a line matched
by `outline-regexp'. Otherwise it returns garbage.
If this is called at a normal headline, the level is the number of stars.
Use `org-reduced-level' to remove the effect of `org-odd-levels'."
(save-excursion
(looking-at org-outline-regexp)
(1- (- (match-end 0) (match-beginning 0)))))
(if (not (condition-case nil
(org-back-to-heading t)
(error nil)))
0
(looking-at org-outline-regexp)
(1- (- (match-end 0) (match-beginning 0))))))
(defvar org-font-lock-keywords nil)