help-gnu-emacs
[Top][All Lists]
Advanced

[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: Fri, 24 May 2013 16:06:19 +0200
User-agent: Gnus/5.130002 (Ma Gnus v0.2) Emacs/24.3 (gnu/linux)

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

>> 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.
>
> It would seem like it would be a lot simpler to write a loop that simply
> erases your "cookies" without paying attention to the visibility state.
>
> "do and then undo" is always a high-risk way to do nothing, so if you
> can really do nothing instead, it's always a major reliability gain.
> Your use of an indirect buffer luckily saves you from having to "do and
> undo".  But indirect buffers suck.
>
> BTW, rather than "insert" your cookies in the text (which has lots of
> undesirable side effects, such as being visible in the saved file), why
> not use overlays (in which case org-hlc-hide-hidden-lines-cookies would
> just be a single call to remove-overlays).

Thanks for the tips. 

I found out that a similar library already existed (org-weights.el by
Francois Pinard) which is based of overlays. So I forked his code and
merged my code/ideas into it. Its still a bit buggy, but here are a few
examples of what this (extended) library can do now (I posted this
already on the Org-mode list). Don't bother about the numbers, they are
made up, since I cannot copy overlays:

1. Org-mode/subtree-weights:

,-----------------------------------------------
| * Header 1                       *    2 + 1...
| ** Header 2a                     **   1
|
| text text text text text
| text text text text text
|
| ** Header 2b                     **   1
`-----------------------------------------------

2. Outshine Emacs Lisp/subtree-weights:

,--------------------------------------------------
| ;; * Header 1                       *    2 + 1...
| ;; ** Header 2a                     **   1
|
| text text text text text
| text text text text text
|
| ;; ** Header 2b                     **   1
|
`--------------------------------------------------

3. Conventional Emacs-Lisp/hidden-lines-cookies

,--------------------------------
| ;;; Header 1   [#1]
| ;;;; Header 2a  [#4]
|
| text text text text text
| text text text text text
|
| ;;;; Header 2b [#2]
|
`--------------------------------

4. Outshine PicoLisp/hidden-lines-cookies

,--------------------------------
| ## * Header 1   [#1]
| ## ** Header 2a  [#4]
|
| text text text text text
| text text text text text
|
| ## ** Header 2b [#2]
|
`--------------------------------

The original repo is at:

,--------------------------------------
| https://github.com/pinard/org-weights
`--------------------------------------

you can find my fork with the extended version here:

,------------------------------------
| https://github.com/tj64/org-weights
`------------------------------------


-- 
cheers,
Thorsten




reply via email to

[Prev in Thread] Current Thread [Next in Thread]