Function: org-fold-show-set-visibility

org-fold-show-set-visibility is a byte-compiled function defined in org-fold.el.gz.

Signature

(org-fold-show-set-visibility DETAIL)

Documentation

Set visibility around point according to DETAIL.

DETAIL is either nil, minimal, local, ancestors, ancestors-full, lineage, tree, canonical or t. See org-show-context-detail for more information.

Aliases

org-show-set-visibility (obsolete since 9.6)

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-fold.el.gz
(defvar org-pretty-entities); Defined in org.el
(defun org-fold-show-set-visibility (detail)
  "Set visibility around point according to DETAIL.
DETAIL is either nil, `minimal', `local', `ancestors',
`ancestors-full', `lineage', `tree', `canonical' or t.  See
`org-show-context-detail' for more information."
  ;; Show current heading and possibly its entry, following headline
  ;; or all children.
  (if (and (org-at-heading-p) (not (eq detail 'local)))
      (org-fold-heading nil)
    (org-fold-show-entry)
    ;; If point is hidden make sure to expose it.
    (when (org-invisible-p)
      ;; FIXME: No clue why, but otherwise the following might not work.
      (redisplay)
      (let ((region (org-fold-get-region-at-point)))
        ;; Reveal emphasis markers.
        (when (eq detail 'local)
          (let (org-hide-emphasis-markers
                org-link-descriptive
                org-pretty-entities
                (org-hide-macro-markers nil)
                (region (or (org-find-text-property-region (point) 'org-emphasis)
                            (org-find-text-property-region (point) 'org-macro)
                            (org-find-text-property-region (point) 'invisible)
                            region)))
            ;; Silence byte-compiler.
            (ignore org-hide-macro-markers)
            (when region
              (org-with-point-at (car region)
                (beginning-of-line)
                (let (font-lock-extend-region-functions)
                  (font-lock-fontify-region (max (point-min) (1- (car region))) (cdr region))))))
          ;; Unfold links.
          (when region
            (dolist (spec '(org-link org-link-description))
              (org-fold-region (car region) (cdr region) nil spec))))
        (when region
          (dolist (spec (org-fold-core-folding-spec-list))
            ;; Links are taken care by above.
            (unless (memq spec '(org-link org-link-description))
              (org-fold-region (car region) (cdr region) nil spec))))))
    (unless (org-before-first-heading-p)
      (org-with-limited-levels
       (cl-case detail
	 ((tree canonical t) (org-fold-show-children))
	 ((nil minimal ancestors ancestors-full))
	 (t (save-excursion
	      (outline-next-heading)
	      (org-fold-heading nil)))))))
  ;; Show whole subtree.
  (when (eq detail 'ancestors-full) (org-fold-show-subtree))
  ;; Show all siblings.
  (when (eq detail 'lineage) (org-fold-show-siblings))
  ;; Show ancestors, possibly with their children.
  (when (memq detail '(ancestors ancestors-full lineage tree canonical t))
    (save-excursion
      (while (org-up-heading-safe)
	(org-fold-heading nil)
	(when (memq detail '(canonical t)) (org-fold-show-entry))
	(when (memq detail '(tree canonical t)) (org-fold-show-children))))))