From 3082ea9a30bb9782f233e01c1b312fc8b1651c5e Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Mon, 16 Aug 2010 19:27:38 +0200 Subject: [PATCH] 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. --- lisp/org.el | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 003ab841e..9cb37999c 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -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