emacs-orgmode
[Top][All Lists]
Advanced

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

[Orgmode] Highlighting current header and its contents


From: Tom
Subject: [Orgmode] Highlighting current header and its contents
Date: Sun, 21 Mar 2010 15:51:54 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

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 via email to

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