Function: hywiki-org-to-heading-instance

hywiki-org-to-heading-instance is an interactive and byte-compiled function defined in hywiki.el.

Signature

(hywiki-org-to-heading-instance TITLE &optional N)

Documentation

To the heading whose TITLE is the optional Nth instance in an Org buffer.

If such an instance is not found, trigger an error.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hywiki.el
(defun hywiki-org-to-heading-instance (title &optional n)
  "To the heading whose TITLE is the optional Nth instance in an Org buffer.
If such an instance is not found, trigger an error."
  (interactive "sHeading Title: \nnInstance: ")
  (unless (wholenump n)
    (setq n 1))
  (let ((found nil)
        (exact-heading-regexp (hywiki-org-get-heading-match-regexp title)))
    (save-excursion
      (goto-char (point-min))
      ;; Search for exact heading and then extract the title
      (when (re-search-forward exact-heading-regexp nil t n)
        (setq found (line-beginning-position))))
    (if found
        (progn
          (goto-char found)
          ;; Ensure the heading is visible if folded
          (if (version< org-version "9.6")
              (with-suppressed-warnings ((obsolete org-show-entry))
                (org-show-entry))
            (org-fold-show-entry))
          ;; (message "Instance %d of '%s'" n title)
          t)
      (error "(hywiki-org-to-heading-instance): Could not find %d instance(s) of '%s' in \"%s\""
             n title (or buffer-file-name (current-buffer))))))