From 3a594dfa9967ed4fd70aae04559dde757fb21b1b Mon Sep 17 00:00:00 2001 From: Michael Brand Date: Mon, 6 May 2019 18:17:52 +0200 Subject: [PATCH 1/2] org-get-heading: New parameter no-cookie * lisp/ol.el (org-link-search): Remove regexps for comment and cookie. * lisp/org.el (org-get-heading:): New parameter no-cookie used above. --- lisp/ol.el | 10 ++-------- lisp/org.el | 11 +++++++++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lisp/ol.el b/lisp/ol.el index a6f76a39f..f5bd63e96 100644 --- a/lisp/ol.el +++ b/lisp/ol.el @@ -1108,18 +1108,12 @@ of matched result, which is either `dedicated' or `fuzzy'." (format "%s.*\\(?:%s[ \t]\\)?.*%s" org-outline-regexp-bol org-comment-string - (mapconcat #'regexp-quote words ".+"))) - (cookie-re "\\[[0-9]*\\(?:%\\|/[0-9]*\\)\\]") - (comment-re (format "\\`%s[ \t]+" org-comment-string))) + (mapconcat #'regexp-quote words ".+")))) (goto-char (point-min)) (catch :found (while (re-search-forward title-re nil t) (when (equal words - (split-string - (replace-regexp-in-string - cookie-re "" - (replace-regexp-in-string - comment-re "" (org-get-heading t t t))))) + (split-string (org-get-heading t t t t t))) (throw :found t))) nil))) (beginning-of-line) diff --git a/lisp/org.el b/lisp/org.el index 94713a7e5..48f7874ac 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -6938,12 +6938,14 @@ So this will delete or add empty lines." (insert (make-string n ?\n)) (move-to-column column))) -(defun org-get-heading (&optional no-tags no-todo no-priority no-comment) +(defun org-get-heading (&optional + no-tags no-todo no-priority no-comment no-cookie) "Return the heading of the current entry, without the stars. When NO-TAGS is non-nil, don't include tags. When NO-TODO is non-nil, don't include TODO keywords. When NO-PRIORITY is non-nil, don't include priority cookie. When NO-COMMENT is non-nil, don't include COMMENT string. +When NO-COOKIE is non-nil, don't include cookie string. Return nil before first heading." (unless (org-before-first-heading-p) (save-excursion @@ -6958,7 +6960,12 @@ Return nil before first heading." (replace-regexp-in-string (eval-when-compile (format "\\`%s[ \t]+" org-comment-string)) - "" h)) + "" + (if no-cookie + (replace-regexp-in-string + "\\[[0-9]*\\(?:%\\|/[0-9]*\\)\\]" + "" h) + h))) (h h))) (tags (and (not no-tags) (match-string 5)))) (mapconcat #'identity -- 2.20.1