all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Thorsten Jolitz <tjolitz@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Is there a save-outline-visibility excursion or so?
Date: Thu, 23 May 2013 12:43:40 +0200	[thread overview]
Message-ID: <87k3mqrn6r.fsf@gmail.com> (raw)
In-Reply-To: jwv8v36jyld.fsf-monnier+gmane.emacs.help@gnu.org

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> I wonder if there is something like a 'save-excursion' for outline
>> visibility around?
>
> Most Elisp functions are unaffected by text's (in)visibility, so I'm
> curious about the kind of code you want to run within such
> save-outline-visibility.

I use it in 'org-hlc-hide-hidden-lines-cookies' from 

,-------------------------------------------------------
| https://github.com/tj64/org-hlc/blob/master/org-hlc.el
`-------------------------------------------------------

(works for org-mode and outline alike)

A hidden-line-cookie is only written, if the headline is folded, and
deleted if it is expanded. This is done by
'org-hlc-write-hidden-lines-cookies'. Thus to delete all cookies, I
temporarily expand all subtrees, call the function, and then go back to
the former visibility state and point position.

,------------------------------------------------------------
| (defun org-hlc-hide-hidden-lines-cookies ()
|   "Delete all hidden-lines cookies."
|   (interactive)
|   (let* ((base-buf (point-marker))
|          (indirect-buf-name
|           (generate-new-buffer-name
|            (buffer-name (marker-buffer base-buf)))))
|     (clone-indirect-buffer indirect-buf-name nil 'NORECORD)
|     (save-excursion
|       (switch-to-buffer indirect-buf-name)
|       (show-all)
|       (let ((indirect-buf (point-marker)))
|         (org-hlc-write-hidden-lines-cookies)
|         (switch-to-buffer (marker-buffer base-buf))
|         (kill-buffer (marker-buffer indirect-buf))
|         (set-marker indirect-buf nil))
|       (set-marker base-buf nil)))
|   (setq org-hlc-hidden-lines-cookies-on-p nil))
`------------------------------------------------------------

PS 

A hidden-lines-cookie looks like this, showing the number of hidden lines:

,-----------------
| *** Headline [#165]
`-----------------

-- 
cheers,
Thorsten




  reply	other threads:[~2013-05-23 10:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-22  9:13 Is there a save-outline-visibility excursion or so? Thorsten Jolitz
2013-05-22  9:18 ` Jambunathan K
2013-05-22 10:12   ` Thorsten Jolitz
2013-05-22 10:25   ` Thorsten Jolitz
2013-05-22 12:39     ` Jambunathan K
2013-05-22 13:41       ` Thorsten Jolitz
2013-05-23  1:05 ` Stefan Monnier
2013-05-23 10:43   ` Thorsten Jolitz [this message]
2013-05-23 13:09     ` Stefan Monnier
2013-05-24 14:06       ` Thorsten Jolitz

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=87k3mqrn6r.fsf@gmail.com \
    --to=tjolitz@gmail.com \
    --cc=help-gnu-emacs@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.