Open
Description
Suppose the org file starts with org-startup-folded != 'showeverything, and valign-mode is called as part of an org-mode-hook
Then,
(if valign-mode
(progn
(add-hook 'jit-lock-functions #'valign-region 98 t)
... [code block]
(jit-lock-refontify))
This causes tables that are currently under invisible headlines to be crooked. User has to press TAB on the table to align again manually.
Currently doing the following as a temporary solution
(with-eval-after-load 'valign
(defun valign-org-cycle-refontification (state)
"Refontify only the visible part affected by `org-cycle`.
STATE is a symbol indicating the new visibility state."
(when (bound-and-true-p valign-mode)
(cond
;; Expand direct children: Only refontify from current headline to its children
((eq state 'children)
(let ((start (point))
(end (save-excursion (outline-next-heading) (point))))
(jit-lock-refontify start end)))
;; Expand full subtree: Refontify from headline to subtree end
((eq state 'subtree)
(let ((start (point))
(end (save-excursion (org-end-of-subtree t t))))
(jit-lock-refontify start end)))
;; Fully expanded: Refontify everything
((eq state 'all)
(jit-lock-refontify (point-min) (point-max))))))
(defun valign--refontification-advice ()
(if valign-mode
(add-hook 'org-cycle-hook #'valign-org-cycle-refontification 98 'local)
(remove-hook 'org-cycle-hook #'valign-org-cycle-refontification 'local)))
(add-hook 'valign-mode-hook #'valign--refontification-advice))
probably not the most efficient or elegant way to solve it, but it works for me currently. Please let me know if any elegant other solution exists.
org-fold-core-style = overlays)
Metadata
Metadata
Assignees
Labels
No labels