[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Is there a save-outline-visibility excursion or so?
From: |
Thorsten Jolitz |
Subject: |
Re: Is there a save-outline-visibility excursion or so? |
Date: |
Thu, 23 May 2013 12:43:40 +0200 |
User-agent: |
Gnus/5.130002 (Ma Gnus v0.2) Emacs/24.3 (gnu/linux) |
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