emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Carsten Dominik <carsten.dominik@gmail.com>
To: Piotr Zielinski <piotr.zielinski@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Autocollapse of outline nodes
Date: Fri, 12 May 2006 06:35:17 +0200	[thread overview]
Message-ID: <58e023ea25ca8bf21c319c581dc71430@gmail.com> (raw)
In-Reply-To: <3c12eb8d0605111826m7ebdf5d5mdab748c16f04a225@mail.gmail.com>

Great.

I did no know about get-buffer-window-list, this makes it a lot easier.

- Carsten

On May 12, 2006, at 3:26, Piotr Zielinski wrote:

> 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)
>
>

--
Carsten Dominik
Sterrenkundig Instituut "Anton Pannekoek"
Universiteit van Amsterdam
Kruislaan 403
NL-1098SJ Amsterdam
phone: +31 20 525 7477

      reply	other threads:[~2006-05-12  4:35 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
2006-05-12  4:35     ` Carsten Dominik [this message]

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

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=58e023ea25ca8bf21c319c581dc71430@gmail.com \
    --to=carsten.dominik@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=piotr.zielinski@gmail.com \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).