From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Brand Subject: Re: suggestion: simplify depth stepping of document structure (outline) visibility Date: Wed, 14 Oct 2009 14:24:50 +0200 Message-ID: <4AD5C312.7010703@alumni.ethz.ch> References: <4AB0000D.5000004@alumni.ethz.ch> <4AB00E6F.4090501@alumni.ethz.ch> <873a6nlopp.fsf@gollum.intra.norang.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1My2uY-0002FQ-4P for emacs-orgmode@gnu.org; Wed, 14 Oct 2009 08:24:58 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1My2uT-0002C7-Ab for emacs-orgmode@gnu.org; Wed, 14 Oct 2009 08:24:57 -0400 Received: from [199.232.76.173] (port=48532 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1My2uT-0002C4-40 for emacs-orgmode@gnu.org; Wed, 14 Oct 2009 08:24:53 -0400 Received: from mail01.solnet.ch ([212.101.4.135]:62685) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1My2uS-00059f-N6 for emacs-orgmode@gnu.org; Wed, 14 Oct 2009 08:24:52 -0400 In-Reply-To: <873a6nlopp.fsf@gollum.intra.norang.ca> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Bernt Hansen , emacs-orgmode@gnu.org Hi all, One reply is not that much feedback yet..., maybe I tried to be detailed but was not clear enough? Ok, I thought after having submitted a few bug reports before, it would be good to contribute in a way a bit more constructive this time ;-) and implemented what I have described in my previous post for headings (not for list elements). For those who are interested in trying it out: First you will have to upgrade to org-version 6.31a or newer (or take into account http://thread.gmane.org/gmane.emacs.orgmode/17441) and then put the code at the end of this post e. g. into your .emacs file and start a new Emacs. Use `C->' and `C-<' repeatedly back and forth on your files that have at least a few heading levels and tell how useful you find it. I find the usage of my-orgstruct-dive very intuitive in contrast to the complicated look of both the description in my previous post and my implementation here. As a nice side effect this function also brings two functionalities from outline-mode to org-mode which I am missing in org-mode: outline-mode-`C-c C-q' (hide everything lower than heading level at point (cursor)) and outline-mode-`C-c C-i' (show direct subheadings but not body of heading at point). ------------------------------------------------------------ (global-set-key (kbd "C->") 'my-orgstruct-dive) (global-set-key (kbd "C-<") 'my-orgstruct-dive-out) (defvar my-orgstruct-dive-level 0) (defun my-orgstruct-dive-out () "Wrapper to simplify comparison with last-command in my-orgstruct-dive" (interactive) (my-orgstruct-dive t)) (defun my-orgstruct-dive (&optional dive-out) "Make visible one heading level more or less. return value: undefined. dive-out: If nil dive in, else dive out." (interactive) ;; determine new level (if (or (eq last-command 'my-orgstruct-dive) (eq last-command 'my-orgstruct-dive-out)) ;; command repetition, increase/decrease level (setq my-orgstruct-dive-level (+ my-orgstruct-dive-level (if dive-out '-1 '1))) ;; init level to that of point (setq my-orgstruct-dive-level (if (outline-on-heading-p) (org-reduced-level (save-excursion (beginning-of-line) (org-outline-level))) '0))) ;; update heading visibility (when (or (<= my-orgstruct-dive-level 0) (<= 1000 my-orgstruct-dive-level)) (setq my-orgstruct-dive-level 1)) (org-shifttab my-orgstruct-dive-level)) ------------------------------------------------------------