Use a better regexp to find a refile target headline

* lisp/org.el (org-complex-heading-regexp-format): Document the variable.
(org-get-refile-targets): Use `org-complex-heading-regexp-format' to
make the regular expression for matching the headline.

Now we use the format for the complex heading regexp, which means that
Changing the TODO state, level, priority, or tags of a heading will
still allow the heading to be matched by the regexp.
This commit is contained in:
Carsten Dominik 2010-08-16 19:27:38 +02:00
parent 56cf6ad42d
commit 3082ea9a30
1 changed files with 7 additions and 10 deletions

View File

@ -4038,7 +4038,11 @@ group 3: Priority cookie
group 4: True headline
group 5: Tags")
(make-variable-buffer-local 'org-complex-heading-regexp)
(defvar org-complex-heading-regexp-format nil)
(defvar org-complex-heading-regexp-format nil
"Printf format to make regexp to match an exact headline.
This regexp will match the headline of any node which hase the exact
headline text that is put into the format, but may have any TODO state,
priority and tags.")
(make-variable-buffer-local 'org-complex-heading-regexp-format)
(defvar org-todo-line-tags-regexp nil
"Matches a headline and puts TODO state into group 2 if present.
@ -9941,15 +9945,8 @@ on the system \"/user@host:\"."
(setq level (org-reduced-level
(- (match-end 1) (match-beginning 1)))
txt (org-link-display-format (match-string 4))
re (concat "^" (regexp-quote
(buffer-substring
(match-beginning 1)
(match-end 4)))))
(if (match-end 5) (setq re (concat
re "[ \t]+"
(regexp-quote
(match-string 5)))))
(setq re (concat re "[ \t]*$"))
re (format org-complex-heading-regexp-format
(regexp-quote (match-string 4))))
(when org-refile-use-outline-path
(setq txt (mapconcat
'org-protect-slash