emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Re: suggestion: simplify depth stepping of document structure


From: Michael Brand
Subject: [Orgmode] Re: suggestion: simplify depth stepping of document structure (outline) visibility
Date: Wed, 14 Oct 2009 14:24:50 +0200
User-agent: Thunderbird 2.0.0.23 (Windows/20090812)

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))
------------------------------------------------------------




reply via email to

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