diff options
author | Carsten Dominik <carsten.dominik@gmail.com> | 2011-03-25 08:05:21 +0100 |
---|---|---|
committer | Carsten Dominik <carsten.dominik@gmail.com> | 2011-03-25 08:05:21 +0100 |
commit | 71e91e3d33dacb18a922df2128f6a89eae925949 (patch) | |
tree | 229167f9ff0da3daab140b68a5c369998f61a5ec | |
parent | 078c01bf3b1742b1015fac9f5bab3a429505f3c6 (diff) | |
download | org-mode-71e91e3d33dacb18a922df2128f6a89eae925949.tar.gz |
Fix bug with resolving outline-path targets when two headings are the same
* lisp/org.el (org-find-olp): Use the level of the correct match to
continue search.
The problem was that a second match of an identical headline on
another level would corrupt the value of LEVEL that is used to set up
the next search stop.
Chao LU writes:
> For org capture template, if I set an template like this:
> ("i" "INBOX" entry (file+olp (concat org-private-dir "/iPrv.org")
> "INBOX" "test") "* %?" :prepend t)
>
> And for the iPrv.org, I have this structure:
> * INBOX
> ** test
>
> Then it works.
>
> But if the first level and the second level happen to have the same
> title (it does happen to me sometimes), like:
> * INBOX
> ** INBOX
>
> ("i" "INBOX" entry (file+olp (concat org-private-dir "/iPrv.org")
> "INBOX" "INBOX") "* %?" :prepend t)
> Then Org will prompt an error.
-rw-r--r-- | lisp/org.el | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lisp/org.el b/lisp/org.el index 27a3949..28025ea 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -14180,7 +14180,7 @@ only headings." (level 1) (lmin 1) (lmax 1) - limit re end found pos heading cnt) + limit re end found pos heading cnt flevel) (unless buffer (error "File not found :%s" file)) (with-current-buffer buffer (save-excursion @@ -14195,13 +14195,13 @@ only headings." (while (re-search-forward re end t) (setq level (- (match-end 1) (match-beginning 1))) (if (and (>= level lmin) (<= level lmax)) - (setq found (match-beginning 0) cnt (1+ cnt)))) + (setq found (match-beginning 0) flevel level cnt (1+ cnt)))) (when (= cnt 0) (error "Heading not found on level %d: %s" lmax heading)) (when (> cnt 1) (error "Heading not unique on level %d: %s" lmax heading)) (goto-char found) - (setq lmin (1+ level) lmax (+ lmin (if org-odd-levels-only 1 0))) + (setq lmin (1+ flevel) lmax (+ lmin (if org-odd-levels-only 1 0))) (setq end (save-excursion (org-end-of-subtree t t)))) (when (org-on-heading-p) (move-marker (make-marker) (point)))))))) |