diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2016-05-01 01:14:10 +0200 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2016-05-01 01:14:10 +0200 |
commit | bb034dfe049a5804b6c0e0b93320409b1116e010 (patch) | |
tree | 14a1eeeedb6302a0acbba7fc1981bede5f9064c9 | |
parent | c112f40d512e657cd688beb65a2dff6d56c62a21 (diff) | |
download | org-mode-bb034dfe049a5804b6c0e0b93320409b1116e010.tar.gz |
`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>
-rw-r--r-- | lisp/org.el | 37 | ||||
-rw-r--r-- | testing/lisp/test-org.el | 25 |
2 files changed, 45 insertions, 17 deletions
diff --git a/lisp/org.el b/lisp/org.el index dfa80c6..dcd2d5a 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -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.") diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index deb6b29..c971625 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -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) |