Reputation: 4173
I'm trying to make a regex in emacs to font-lock tasks, projects and notes in taskpaper files.
Taskpaper is a simple text based format for task management, with the following format:
Project 1:
- Task 1
- Task 2
Note about Task2
Project 2:
- Task 3
Note about Task 3
A general note about something
I'm using a taskpaper mode I found here as a basis (https://github.com/jedthehumanoid/taskpaper.el/blob/master/taskpaper.el). However, this mode is based on space indentation, and it seems that at the moment, the taskpaper format uses tabs to indent.
(setq font-lock-defaults
'(("^.*@done.*$" . font-lock-comment-face)
("^.*:$" . font-lock-function-name-face)
("^[\t]*[^-\t].*[^:]$" font-lock-comment-face)
("@.*" . font-lock-variable-name-face)))
At the moment, the third regex (which should font-lock notes in the comment face) is not working, and I can't see why. Notes are all lines with any indentation that do not begin with a -
and do not end with a :
The strange thing is, in the regex builder, the regex ^[\t]*[^-\t].*[^:]$
successfully matches the notes lines.
I've tried double escaping the \t characters (as \\t) as suggested in some other questions, but this appears to make no difference.
Upvotes: 1
Views: 238
Reputation: 4804
Where a \t is in 3rd expression, put an empty space aside, i.e. [ \t] for [\t] etc. Thus empty spaces an TAB are matched alike. HTH
Upvotes: 1
Reputation: 26144
What makes the third rule different from the others is that the others use a dotted pair, i.e. (xxx . yyy)
whereas the third use list notation, i.e. (xxx yyy)
.
The list notation can also be used, but then you must supply the subexpression to be highlighted, as in (regexp 0 font-lock-comment-face)
.
Upvotes: 2
Reputation: 569
Part of the problem probably has to do with the use of the * character. Since it matches 0 or more times, you're not actually requiring that the line begin with a tab.
Upvotes: 0