Reputation: 1241
I really like org and org-bullets and I'd like to entirely hide the leading asterisks for headers so that the headers (and their nifty icons/bullets) are flush with the left of the window.
I found this function in a Reddit thread, and it seems to mostly do what I want, except that it removes ALL of the asterisks. I want to keep the last one.
(defun me-org-mode-remove-stars ()
(font-lock-add-keywords
nil
'(("^\\*+ "
(0
(prog1 nil
(put-text-property (match-beginning 0) (match-end 0)
'invisible t)))))))
(add-hook 'org-mode-hook #'me-org-mode-remove-stars)
Being rather new to emacs and lisp in general, my first thought was to just modify the regular expression, but it turns out there's no lookahead here so I'm having trouble expressing "select all asterisks in a series except an asterisk followed by a space character" or something similar.
Is there a right way to go about this?
Upvotes: 1
Views: 1358
Reputation: 87109
You can just set the variable org-hide-leading-stars
to the t
, then it will hide all leading stars from the header. You can even enable or disable that for specific files using the org-mode directives. See built-in documentation (C-h v org-hide-leading-stars
) & info pages for more details. (I personally use it)
P.S. There is another way to do that - via org-ident-mode
, but I haven't tried it.
Upvotes: 1