emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Tom <levelhalom@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Highlighting current header and its contents
Date: Sun, 21 Mar 2010 15:51:54 +0000 (UTC)	[thread overview]
Message-ID: <loom.20100321T164222-668@post.gmane.org> (raw)

One of my main gripes with orgmode is often I cannot make out
clearly when the text content of an opened header ends and the
next header begins, because there is no apparent visual
indication.

Of course, I can add empty lines manually to the end of the
content, but this solution is not really satisfying (I don't need
empty lines there, I add them only to see better where the
content ends).

I'm still thinking of a proper solution for this problem, but I'm
posting one of my attempts for the time being which some may find
useful. It highlights the header the cursor is in and its contents with a
different background color:


(make-variable-buffer-local 'my-org-highlight-overlay)

(add-hook 'post-command-hook 'my-org-highlight)


(defun my-org-highlight ()
  (when (and (eq major-mode 'org-mode)
             (sit-for 0.1))
    (unless my-org-highlight-overlay
      (setq my-org-highlight-overlay (make-overlay 0 0))
      (overlay-put my-org-highlight-overlay 'face '(:background "azure")))

    (let ((header (save-excursion
                    (beginning-of-line)
                    (looking-at outline-regexp))))

      (move-overlay my-org-highlight-overlay
                    (save-excursion
                      (if header
                          (beginning-of-line)
                        (outline-previous-visible-heading 1))
                      (point))
                    (save-excursion
                      (outline-next-visible-heading 1)
                      (point))))))

             reply	other threads:[~2010-03-21 15:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-21 15:51 Tom [this message]
2010-03-21 17:59 ` Highlighting current header and its contents Dan Davison
2010-03-21 18:22   ` Tom

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=loom.20100321T164222-668@post.gmane.org \
    --to=levelhalom@gmail.com \
    --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).