Q: how do I change org-mode's definition of a commented line?

According to the manual, org-mode comments work as follows:

Lines starting with zero or more whitespace characters followed by one '#' and a whitespace are treated as comments and will never be exported. Also entire subtrees starting with the word ‘COMMENT’ will never be exported. Finally, regions surrounded by '#+BEGIN_COMMENT' ... '#+END_COMMENT' will not be exported.

I'd like to adjust the single-# notation to allow multiple #s so that Emacs will correctly fontify such lines as comments:

comment lines

I'm doing this because I have timestamp blocks at the top of the file that start with multiple comment characters:

comment block

However, I can't figure out which variables I need to adjust. I've tried modifying comment-start, comment-start-skip, and even comment-padding, but with no luck (org-comment-string appears not to be relevant here).

So: how can I get org-mode to treat lines starting with multiple #s as comments?

  • 2
    Curious! Poking around in the source it looks like the "# " comment definition is hard-coded in a number of places, which may make it difficult to modify. – Tyler Dec 2 '14 at 15:32

The following is a partial answer that addresses the cosmetic issue (get the font-locking visuals correct), but it does not actually modify what org-mode considers to be a comment (e.g., for exporting purposes).

Add a font lock keyword:

(font-lock-add-keywords 'org-mode '(("^\\s-*#+\\s-?.*" . 'font-lock-comment-face)))
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.