From: Gregor Kappler <g.kappler@gmx.net>
To: emacs-orgmode@gnu.org
Subject: adapted org-flag-drawer to hide newlines of consecutive drawers to save lines
Date: Tue, 12 Nov 2013 16:47:14 +0100 [thread overview]
Message-ID: <87iovx7hbx.fsf@univie.ac.at> (raw)
Often several consecutive drawers follow the headline in my setup.
Maybe this code to hide newlines after drawers is of some use.
When drawers are hidden this wastes three lines of screen real estate
: * heading
: :LOGBOOK:...
: :CLOCK:...
: :PROPERTIES:...
per line.
I adapted org-flag-drawer to hide the newlines as well if another drawer
is following:
: * heading
: :LOGBOOK:...:CLOCK:...:PROPERTIES:...
This lead to a much denser editing experience.
Maybe this is not the best way to do this. But this trick caused no
troubles for me during the last months. All the best!
Gregor
#+BEGIN_SRC emacs-lisp
(defun org-flag-drawer (flag)
"When FLAG is non-nil, hide the drawer we are within,
including the newline at end of a drawer,
yet only if another drawer is following.
If FLAG is nil, make drawer it visible."
(save-excursion
(beginning-of-line 1)
(when (looking-at "^[ \t]*:[a-zA-Z][a-zA-Z0-9]*:")
(let ((b (match-end 0))
(selective-display-ellipses nil))
(if (re-search-forward
"^[ \t]*:END:"
(save-excursion (outline-next-heading) (point)) t)
(outline-flag-region b (save-excursion
(forward-line)
(if (looking-at org-drawer-regexp)
(point-at-bol)
(match-end 0)))
flag)
(error ":END: line missing at position %s in buffer %s" b (buffer-name)))))))
#+END_SRC
Refererences
-- org.el::org-cycle-hide-drawers
--
next reply other threads:[~2013-11-12 15:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-12 15:47 Gregor Kappler [this message]
2013-11-12 21:46 ` adapted org-flag-drawer to hide newlines of consecutive drawers to save lines Bastien
2013-11-13 8:20 ` Nicolas Goaziou
2013-11-13 8:52 ` Bastien
2013-11-13 11:24 ` Nicolas Goaziou
2013-11-13 11:43 ` Bastien
2013-11-14 17:43 ` Nicolas Goaziou
2013-11-14 22:55 ` Bastien
2013-11-15 16:56 ` Nicolas Goaziou
2013-11-15 19:30 ` Bastien
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=87iovx7hbx.fsf@univie.ac.at \
--to=g.kappler@gmx.net \
--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).