From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thorsten Jolitz Newsgroups: gmane.emacs.help Subject: Re: Is there a save-outline-visibility excursion or so? Date: Fri, 24 May 2013 16:06:19 +0200 Message-ID: <87zjvkbhgk.fsf@gmail.com> References: <877gircr8b.fsf@gmail.com> <87k3mqrn6r.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1369404413 12256 80.91.229.3 (24 May 2013 14:06:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 24 May 2013 14:06:53 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri May 24 16:06:53 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Ufsdu-0007yD-L3 for geh-help-gnu-emacs@m.gmane.org; Fri, 24 May 2013 16:06:50 +0200 Original-Received: from localhost ([::1]:34721 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ufsdu-00023i-6I for geh-help-gnu-emacs@m.gmane.org; Fri, 24 May 2013 10:06:50 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:45033) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ufsdd-000217-I8 for help-gnu-emacs@gnu.org; Fri, 24 May 2013 10:06:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ufsdb-0003Kn-GB for help-gnu-emacs@gnu.org; Fri, 24 May 2013 10:06:33 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:47566) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ufsdb-0003Kc-9F for help-gnu-emacs@gnu.org; Fri, 24 May 2013 10:06:31 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UfsdZ-0007jA-US for help-gnu-emacs@gnu.org; Fri, 24 May 2013 16:06:29 +0200 Original-Received: from e178061221.adsl.alicedsl.de ([85.178.61.221]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 24 May 2013 16:06:29 +0200 Original-Received: from tjolitz by e178061221.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 24 May 2013 16:06:29 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 97 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: e178061221.adsl.alicedsl.de User-Agent: Gnus/5.130002 (Ma Gnus v0.2) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:A0rAK5GKXuI8fNQx8gRiooYidWg= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:91021 Archived-At: Stefan Monnier 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