This thread is a continuation of 
"ENB: Completing #578: support for org-mode tags", focused exclusively on 
the declutter regex.

*tl;dr:* Read the summary.  

My original attempt was:

RULE ^([^:]*):([\w_@]+:)+\s*$
REPLACE \1

This is *almost* what we want.  It will compute \1 properly for these 
strings:

abc :tag1:tag2:
abc:tag1:tag2:

but not if the *head* (everything before the tags) contains a colon.  This 
fails:

abc:xyz :tag1:tag2:

Imo, if any regex is going to work, it is likely to involve a lookahead 
assertion.  Indeed, after considerable experimentation, the following 
*almost* works:

RULE ^((.(?!:[\w_@]+:))+)\s*:([\w_@]+:)+\s*$
REPLACE \1

Now the following all match, setting \1 correctly.

abc :tag1:tag2:
abc:xyz :tag1:tag2:

However, the space before the first tag is required.  These do *not* match:

abc:tag1:tag2:
abc:xyz:tag1:tag2:

I'm not sure whether whitespace will *always* precede the first org-mode 
tag.  Leo's org-mode writer does write a single space before the list of 
tags.

*Summary*

Rev 59bd6b1 adds two *disabled *declutter rules for org-mode tags.

*Rule 1*: This rule does not allow ":" before the trailing list of tags:

RULE ^([^:]*):([\w_@]+:)+\s*$
REPLACE \1

*Rule 2*: This rule *does *allow ":" before the trailing list of tags, but 
*only* if the list of tags is preceded by at least one blank.  

RULE ^((.(?!:[\w_@]+:))+)\s*:([\w_@]+:)+\s*$
REPLACE \1

Leo's org-mode writer supplies that blank, but I'm not sure about headlines 
produced by org-mode itself.

Imo, rule 2 is preferable.  If the rule fails when tags are actually 
present, it is easy enough to add the required blank. As soon as the user 
does so, the tags will disappear.

What do you think, Amigos?

Edward
<https://groups.google.com/forum/#!topic/leo-editor/Z7UaiZyvq-k>

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to