`org-show-context' always displays point

* lisp/org.el (org-show-set-visibility): Always show point, even when it
  is hidden in a block or a drawer.

* testing/lisp/test-org.el (test-org/show-set-visibility): Add tests.

Reported-by: Derek Feichtinger <dfeich@gmail.com>
<http://permalink.gmane.org/gmane.emacs.orgmode/106744>
This commit is contained in:
Nicolas Goaziou 2016-05-01 01:14:10 +02:00
parent c112f40d51
commit bb034dfe04
2 changed files with 45 additions and 17 deletions

View File

@ -13945,28 +13945,33 @@ be shown."
DETAIL is either nil, `minimal', `local', `ancestors', `lineage',
`tree', `canonical' or t. See `org-show-context-detail' for more
information."
(unless (org-before-first-heading-p)
;; Show current heading and possibly its entry, following headline
;; or all children.
(if (and (org-at-heading-p) (not (eq detail 'local)))
(org-flag-heading nil)
(org-show-entry)
;; Show current heading and possibly its entry, following headline
;; or all children.
(if (and (org-at-heading-p) (not (eq detail 'local)))
(org-flag-heading nil)
(org-show-entry)
;; If point is hidden within a drawer or a block, make sure to
;; expose it.
(dolist (o (overlays-at (point)))
(when (memq (overlay-get o 'invisible) '(org-hide-block outline))
(delete-overlay o)))
(unless (org-before-first-heading-p)
(org-with-limited-levels
(cl-case detail
((tree canonical t) (org-show-children))
((nil minimal ancestors))
(t (save-excursion
(outline-next-heading)
(org-flag-heading nil))))))
;; Show all siblings.
(when (eq detail 'lineage) (org-show-siblings))
;; Show ancestors, possibly with their children.
(when (memq detail '(ancestors lineage tree canonical t))
(save-excursion
(while (org-up-heading-safe)
(org-flag-heading nil)
(when (memq detail '(canonical t)) (org-show-entry))
(when (memq detail '(tree canonical t)) (org-show-children)))))))
(org-flag-heading nil)))))))
;; Show all siblings.
(when (eq detail 'lineage) (org-show-siblings))
;; Show ancestors, possibly with their children.
(when (memq detail '(ancestors lineage tree canonical t))
(save-excursion
(while (org-up-heading-safe)
(org-flag-heading nil)
(when (memq detail '(canonical t)) (org-show-entry))
(when (memq detail '(tree canonical t)) (org-show-children))))))
(defvar org-reveal-start-hook nil
"Hook run before revealing a location.")

View File

@ -4741,7 +4741,30 @@ Paragraph<point>"
(should (equal '(0 1 3 4 5 7 12 13)
(funcall list-visible-lines 'canonical t)))
(should (equal '(0 1 3 4 5 7 8 9 11 12 13)
(funcall list-visible-lines 'canonical nil)))))
(funcall list-visible-lines 'canonical nil))))
;; When point is hidden in a drawer or a block, make sure to make it
;; visible.
(should-not
(org-test-with-temp-text "#+BEGIN_QUOTE\nText\n#+END_QUOTE"
(org-hide-block-toggle)
(search-forward "Text")
(org-show-set-visibility 'minimal)
(org-invisible-p2)))
(should-not
(org-test-with-temp-text ":DRAWER:\nText\n:END:"
(org-flag-drawer t)
(search-forward "Text")
(org-show-set-visibility 'minimal)
(org-invisible-p2)))
(should-not
(org-test-with-temp-text
"#+BEGIN_QUOTE\n<point>:DRAWER:\nText\n:END:\n#+END_QUOTE"
(org-flag-drawer t)
(forward-line -1)
(org-hide-block-toggle)
(search-forward "Text")
(org-show-set-visibility 'minimal)
(org-invisible-p2))))
(provide 'test-org)