Add support for new switches to org-get-heading

* lisp/org.el (org-get-heading): NO-COMMENT tag, if non-nil, will not
return the COMMENT string with heading.  Likewise, NO-PRIORITY, if
non-nil, will not return the priority cookie.
This commit is contained in:
Matt Price 2017-01-17 18:03:12 -05:00 committed by Nicolas Goaziou
parent 4353deb0de
commit 53ee147f45
1 changed files with 19 additions and 18 deletions

View File

@ -8015,29 +8015,30 @@ So this will delete or add empty lines."
(insert empty-lines) (insert empty-lines)
(move-to-column column))) (move-to-column column)))
(defun org-get-heading (&optional no-tags no-todo) (defun org-get-heading (&optional no-tags no-todo no-priority no-comment)
"Return the heading of the current entry, without the stars. "Return the heading of the current entry, without the stars.
When NO-TAGS is non-nil, don't include tags. When NO-TAGS is non-nil, don't include tags.
When NO-TODO is non-nil, don't include TODO keywords." 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."
(save-excursion (save-excursion
(org-back-to-heading t) (org-back-to-heading t)
(let ((case-fold-search nil)) (let ((case-fold-search nil))
(cond (looking-at org-complex-heading-regexp)
((and no-tags no-todo) (let ((todo (and (not no-todo) (match-string 2)))
(looking-at org-complex-heading-regexp) (priority (and (not no-priority) (match-string 3)))
;; Return value has to be a string, but match group 4 is (headline (pcase (match-string 4)
;; optional. (`nil "")
(or (match-string 4) "")) ((and (guard no-comment) h)
(no-tags (replace-regexp-in-string
(looking-at (concat org-outline-regexp (eval-when-compile
"\\(.*?\\)" (format "\\`%s[ \t]+" org-comment-string))
"\\(?:[ \t]+:[[:alnum:]:_@#%]+:\\)?[ \t]*$")) "" h))
(match-string 1)) (h h)))
(no-todo (tags (and (not no-tags) (match-string 5))))
(looking-at org-todo-line-regexp) (mapconcat #'identity
(match-string 3)) (delq nil (list todo priority headline tags))
(t (looking-at org-heading-regexp) " ")))))
(match-string 2))))))
(defvar orgstruct-mode) ; defined below (defvar orgstruct-mode) ; defined below