emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Michael Brand <michael.brand@alumni.ethz.ch>
To: Bernt Hansen <bernt@norang.ca>, emacs-orgmode@gnu.org
Subject: Re: suggestion: simplify depth stepping of document structure (outline) visibility
Date: Wed, 14 Oct 2009 14:24:50 +0200	[thread overview]
Message-ID: <4AD5C312.7010703@alumni.ethz.ch> (raw)
In-Reply-To: <873a6nlopp.fsf@gollum.intra.norang.ca>

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	other threads:[~2009-10-14 12:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4AB0000D.5000004@alumni.ethz.ch>
2009-09-15 22:00 ` suggestion: simplify depth stepping of document structure (outline) visibility Michael Brand
2009-09-16  0:26   ` Bernt Hansen
2009-10-14 12:24     ` Michael Brand [this message]
2010-09-01 17:10       ` Michael Brand
2010-09-03  1:26         ` Bastien
2010-09-03  5:01           ` Herbert Sitz
2010-09-03  7:59             ` Michael Brand
2010-09-03  9:05           ` Michael Brand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4AD5C312.7010703@alumni.ethz.ch \
    --to=michael.brand@alumni.ethz.ch \
    --cc=bernt@norang.ca \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).