From: "Piotr Zielinski" <piotr.zielinski@gmail.com>
To: Carsten Dominik <carsten.dominik@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Autocollapse of outline nodes
Date: Fri, 12 May 2006 03:26:48 +0200 [thread overview]
Message-ID: <3c12eb8d0605111826m7ebdf5d5mdab748c16f04a225@mail.gmail.com> (raw)
In-Reply-To: <39e6a980b34a61ebb4e57f452699359c@science.uva.nl>
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)
next prev parent reply other threads:[~2006-05-12 1:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-24 12:15 Autocollapse of outline nodes Piotr Zielinski
2006-04-24 16:08 ` Xavier Maillard
2006-04-26 9:20 ` Carsten Dominik
2006-04-26 12:44 ` Piotr Zielinski
2006-05-12 1:26 ` Piotr Zielinski [this message]
2006-05-12 4:35 ` Carsten Dominik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3c12eb8d0605111826m7ebdf5d5mdab748c16f04a225@mail.gmail.com \
--to=piotr.zielinski@gmail.com \
--cc=carsten.dominik@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.