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: Thu, 23 May 2013 12:43:40 +0200 Message-ID: <87k3mqrn6r.fsf@gmail.com> References: <877gircr8b.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1369305848 32728 80.91.229.3 (23 May 2013 10:44:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 23 May 2013 10:44:08 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu May 23 12:44:08 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 1UfT0C-0008Qw-7t for geh-help-gnu-emacs@m.gmane.org; Thu, 23 May 2013 12:44:08 +0200 Original-Received: from localhost ([::1]:48268 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfT0B-0004Rd-Sp for geh-help-gnu-emacs@m.gmane.org; Thu, 23 May 2013 06:44:07 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:51559) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfT00-0004RN-Ck for help-gnu-emacs@gnu.org; Thu, 23 May 2013 06:43:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UfSzv-0003SC-WF for help-gnu-emacs@gnu.org; Thu, 23 May 2013 06:43:56 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:35055) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfSzv-0003Rp-PR for help-gnu-emacs@gnu.org; Thu, 23 May 2013 06:43:51 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UfSzu-0008HE-Rz for help-gnu-emacs@gnu.org; Thu, 23 May 2013 12:43:50 +0200 Original-Received: from e178190243.adsl.alicedsl.de ([85.178.190.243]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 23 May 2013 12:43:50 +0200 Original-Received: from tjolitz by e178190243.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 23 May 2013 12:43:50 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 55 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: e178190243.adsl.alicedsl.de User-Agent: Gnus/5.130002 (Ma Gnus v0.2) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:RC7/zeyO7PS2p0Ju+GFhQVZ4TU0= 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:90993 Archived-At: Stefan Monnier 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