How to highlight current subtree in org-mode emacs?

How can I make the current subtree more recognizable?

Creating a bold line number in order, or just underlining the entire text of the current subtree, would also be good.

I mean, can someone help me get the elisp code? to achieve this (e.g. underlining the entire subtree)?


I cannot show you the underline, so I have a bold example:

* [1] this is a subtree

some text

** [1.1] subtree n Β° 2

and text too

*** [1.1.1] welcome subtree

** [2] have a nice day

+8
emacs org-mode
source share
1 answer

Download the following definitions

(defun org-subtree-highlight-find-overlay (p1 p2) "Find an overlay with property 'org-subtree-highlight-overlay" (defun org-subtree-highlight-find-overlay01 (overlays) (if overlays (let ((ov (car overlays))) (if (overlay-get ov 'org-subtree-highlight-overlay) ov (org-subtree-highlight-find-overlay01 (cdr overlays)))) nil)) (org-subtree-highlight-find-overlay01 (overlays-in p1 p2))) (defun org-subtree-highlight-toggle () "Toggle subtree highlighting" (interactive) (save-excursion (let* ((p1 (progn (org-back-to-heading t) (point))) (p2 (progn (outline-next-visible-heading 1) (if (and (org-at-heading-p) (not (eobp))) (backward-char 1)) (point))) (ov (org-subtree-highlight-find-overlay p1 p2))) (if ov (delete-overlay ov) (setq ov (make-overlay p1 p2)) (overlay-put ov 'org-subtree-highlight-overlay t) ;; set a format for the subtree (can be also 'bold) (overlay-put ov 'font-lock-face 'underline))))) ;; keybindin example (add-hook 'org-mode-hook (lambda () (local-set-key "\Cc\Ch" 'org-subtree-highlight-toggle))) 

The result should be like this:

emacs screenshot

+2
source share

All Articles