Function: hywiki-org-format-heading

hywiki-org-format-heading is an autoloaded and byte-compiled function defined in hywiki.el.

Signature

(hywiki-org-format-heading HEADING &optional NO-TAGS NO-TODO NO-PRIORITY NO-COMMENT NO-STATS)

Documentation

Return HEADING, without the leading asterisks or a #+TITLE:.

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-STATS is non-nil, don't include statistics in square brackets.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hywiki.el
;;; For Org less than 9.6; derived from `org-get-heading' in "org.el"
;;;###autoload
(defun hywiki-org-format-heading (heading &optional no-tags no-todo
                                          no-priority no-comment no-stats)
  "Return HEADING, without the leading asterisks or a #+TITLE:.
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-STATS is non-nil, don't include statistics in square brackets."
  (when (stringp heading)
    (let ((case-fold-search nil))
      (when (string-match hywiki--org-heading-regexp heading)
        (let ((todo (and (not no-todo) (match-string 2 heading)))
	      (priority (and (not no-priority) (match-string 3 heading)))
	      (headline (pcase (match-string 4 heading)
			  (`nil "")
			  ((and (guard no-comment) h)
			   (replace-regexp-in-string
			    (eval-when-compile
			      (format "\\`%s[ \t]+" org-comment-string))
			    "" h))
			  (h h)))
	      (tags (and (not no-tags) (match-string 5 heading))))

          (when no-stats
            ;; Strip trailing statistics cookies [1/2] or [50%]
            (setq headline
                  (replace-regexp-in-string
                   "\\(?: +\\[[0-9%+/]+\\]\\)+" "" headline)))

	  (mapconcat #'identity
		     (delq nil (list todo priority headline tags))
		     " "))))))