You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Revisiting #27 (I don't have permissions to reopen it), which discusses interactive toggling of property drawers not being in the scope of org-appear, I thought perhaps supporting dynamic toggling instead of interactive toggling is aligned with the philosophy of org-appear - i.e. re-appear-ance of any already hidden property drawer when user:
set the drawer(s) to be hidden at startup; and
set org-appear-autodrawers to non-nil and org-hidden-drawers is non-nil; and
has cursor/point near hidden property drawer, i.e. one or customizable number of lines above or below the drawer
(add-hook'org-mode-hook (lambda () (setq-local org-drawers-hidden nil)))
(defunorg-hide-properties ()
"Hide all org-mode headline property drawers in buffer. Could be slow if it has a lot of overlays."
(interactive)
(save-excursion
(goto-char (point-min))
(while (re-search-forward"^ *:properties:\n\\( *:.+?:.*\n\\)+ *:end:\n"nilt)
(let ((ov_this (make-overlay (match-beginning0) (match-end0))))
(overlay-put ov_this 'display"")
(overlay-put ov_this 'hidden-prop-drawert))))
(setq org-drawers-hidden t))
(defunorg-show-properties ()
"Show all org-mode property drawers hidden by org-hide-properties."
(interactive)
(remove-overlays (point-min) (point-max) 'hidden-prop-drawert)
(setq org-drawers-hidden nil))
(defunorg-toggle-properties ()
"Toggle visibility of property drawers."
(interactive)
(if org-drawers-hidden
(org-show-properties)
(org-hide-properties)))
I have this working prototype:
(defcustomorg-appear-autodrawerst"Non-nil enables automatic toggling of hidden property drawers. Does not have an effect if `org-drawers-hidden' is nil":type'boolean:group'org-appear)
(defvar-local org-appear-unhidden-drawers nil"List of currently unhidden property drawers in the buffer.")
(defunhide-near-point-otherwise-unhide ()
"Dynamically hide or unhide property drawers based on cursor proximity."
(let ((unhidden-drawers-near-point
(cl-loopfor pos in '(-12)
for drawer-near-point = (org-find-overlays'hidden-prop-drawer (line-beginning-position pos))
when drawer-near-point do (overlay-put (car drawer-near-point) 'displaynil) ;; unhide drawer near pointappend drawer-near-point)))
(dolist (previously-unhidden-drawer org-appear-unhidden-drawers)
(unless (member previously-unhidden-drawer unhidden-drawers-near-point)
(overlay-put previously-unhidden-drawer 'display""))) ;; hide previously unhidden drawer no longer near point
(setq-local org-appear-unhidden-drawers unhidden-drawers-near-point)))
(defunorg-appear-dynamic-drawers-visibility--setup ()
"Set up dynamic drawer visibility for Org-mode."
(add-hook'post-command-hook#'hide-near-point-otherwise-unhidenilt))
(defunorg-appear-dynamic-drawers-visibility--cleanup ()
"Remove dynamic drawer visibility for Org-mode."
(remove-hook'post-command-hook#'hide-near-point-otherwise-unhidet))
(add-hook'org-mode-hook#'org-appear-dynamic-drawers-visibility--setup)
(add-hook'org-mode-hook
(lambda () (add-hook'kill-buffer-hook#'org-appear-dynamic-drawers-visibility--cleanupnilt)))
Of course it would be better to implement with org-elements rather than re-search-forward.
The text was updated successfully, but these errors were encountered:
these do not make a drawer automatically re-appear locally at point (when the cursor moves near the hidden overlay)
Yes, that's correct. I mentioned them because they are related packages.
But with respect to implementing a unhide-on-point functionality, I think org-hide-drawers could be retooled for that purpose, since it can hide (with overlays; though I suppose the code could be rewritten to use text properties like org-appear...) drawers when given a drawer element or region. I've done a bit of work integrating org-appear with hiding org-cite citations recently, and as far as I can tell, the above shouldn't be too much work.
Revisiting #27 (I don't have permissions to reopen it), which discusses interactive toggling of property drawers not being in the scope of
org-appear
, I thought perhaps supporting dynamic toggling instead of interactive toggling is aligned with the philosophy oforg-appear
- i.e. re-appear
-ance of any already hidden property drawer when user:org-appear-autodrawers
to non-nil andorg-hidden-drawers
is non-nil; andStarting from functions that hide the properties drawers:
(copied here since the original is now buried in old version of Hitchhiker's-Rough-Guide-to-Org-roam-V2; slightly modified)
I have this working prototype:
Of course it would be better to implement with org-elements rather than
re-search-forward
.The text was updated successfully, but these errors were encountered: