Below is a version of autocollapse that works correctly even if several windows show the same buffer. It periodically collapses outline nodes that are far from the current point position [1].
Piotr [1] http://zerotau.blogspot.com/2006/04/autocollapse-mode-for-emacs.html (defun local-fold-from-level (beg end level) (hide-region-body beg end) (goto-char beg) (unless (looking-at outline-regexp) (outline-next-visible-heading 1)) (while (and (<= (point) end) (not (eobp))) (when (> (outline-level) level) (hide-subtree)) (outline-next-visible-heading 1))) (defun local-contains-point (beg end pointlist) (let ((result)) (dolist (point pointlist result) (setq result (or result (and (>= point beg) (<= point end))))))) (defun local-auto-fold () (save-excursion (let ((pointlist (mapcar 'window-point (get-buffer-window-list (current-buffer) nil t)))) (message "fold: %S: %S" (current-buffer) pointlist) (beginning-of-buffer) (unless (looking-at outline-regexp) (outline-next-visible-heading 1)) (while (not (eobp)) (let ((end (save-excursion (outline-end-of-subtree) (point)))) (if (local-contains-point (point) end pointlist) (outline-next-visible-heading 1) (local-fold-from-level (point) end (outline-level)))))))) (defun local-auto-fold-all () (save-excursion (dolist (buffer (buffer-list)) (set-buffer buffer) (when (eq major-mode 'org-mode) (local-auto-fold))))) (run-with-idle-timer 60 t 'local-auto-fold-all) _______________________________________________ Emacs-orgmode mailing list Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode